Ava
Ava

Reputation: 6053

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?

Upvotes: 5

Views: 18328

Answers (3)

Jingpeng Wu
Jingpeng Wu

Reputation: 522

I spent a lot of time fixing this issue on my MacBook. The gem update --system does not work for me.

At last, putting the following code in the ~/.zshrc file and create a new zsh session works for me.

export GEM_HOME="$HOME/.gem"
export GEM_PATH="$HOME/.gem"

Upvotes: 6

JoJoS
JoJoS

Reputation: 2041

Make sure to update your system rubygems with this command : sudo gem update --system --no-user-install.

bundler use it instead your local version and your bundler version could be incompatible with your system rubygems.

It works for me ;)

Upvotes: 0

mpapis
mpapis

Reputation: 53158

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.

Upvotes: 3

Related Questions