Search code examples
rubypermissionsrubygemsrvmbundler

Why do I get "ERROR: While executing gem ... (Gem::FilePermissionError)"?


I uninstalled RVM and re-installed using a single user installation using:

\curl -L https://get.rvm.io | bash -s stable

When I do bundle, it prompts for:

Enter your password to install the bundled RubyGems to your system:

I tried using the answer in "ERROR: While executing gem … (Gem::FilePermissionError)" which did not fix it.

Then, while trying to install the gem manually, I got:

Gem::InstallError: nokogiri requires Ruby version >= 1.9.2.
An error occurred while installing nokogiri (1.6.0), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.0'` succeeds before bundling.

then running gem install nokogiri -v '1.6.0' returned:

ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions into the /Library/Ruby/Gems/1.8 directory.

I checked all the similar posts on SO, but they didn't solve the problem. What am I missing?


Solution

  • after you install RVM you still need few more steps:

    1. Load RVM to the current shell:

      source ~/.rvm/scripts/rvm
      

      Usually this would not be needed if you close and open your terminal again

    2. Install ruby:

      rvm install ruby
      
    3. Use ruby:

      rvm use ruby
      

    The last step is very important as your error message mentioned system ruby not the one controlled by RVM.