kpaul kpaul - 1 year ago 181
Ruby Question

Installing bundler gives me "you don't have write permissions" error

I had used ruby version manager (

) to install a new version of ruby. Running the command
rvm rubies
shows all the version of rubies that are installed. The list is given below.

rvm rubies

ruby-1.9.3-p551 [ x86_64 ]
ruby-2.1.5 [ x86_64 ]
ruby-2.2.4 [ x86_64 ]
* ruby-2.3.0 [ x86_64 ]
ruby-2.3.1 [ x86_64 ]

# => - current
# =* - current && default
# * - default

I tried to run the command
bundle exec rake rb:mgirate
and I get the following error.

/usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/dependency.rb:319:in `to_specs': Could not find 'bundler' (>= 0.a) among 5 total gem(s) (Gem::LoadError)
Checked in 'GEM_PATH=:/nix/.nix-profile/lib/ruby/gems', execute `gem env` for more information

The error states that bundler isn't installed. I ran the command
gem install bundle
and I get the following error.

ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /nix/.nix-profile/lib/ruby/gems directory.

It says that I don't have write permissions. I googled the error and it has something to do with updating ruby and ruby version. The reason why I updated to a new ruby version was because
heroku run rake db:seed
wasn't seeding data in production. I though it might be due to compatibility issues. Therefore, I decided to update to the new version of ruby. The servers, postgresql and everything else works fine. I can't run bundle because I can't install the gem. Any hep would be greatly appreciated. Thanks!

Answer Source

The problem was fixed by switching to the ruby version 2.3.0 by running the command rvm user 2.3.0. Once that is done you should restart the workspace. The reason for the error was the fact that when you switch ruby version it also changes gem files. Therefore, it wasn't able to recognize the gems.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download