Rvm Gem Permissions Error

RVM gem permissions error

You missed to use ruby, you can do it with:

rvm use 1.9.3 --install

In case 1.9.3 was not installed, this command will also install it!

It also looks you are using Ubuntu, make sure you are not using RVM from Ubuntu package - that thing is broken! You can find instruction how to fix it here: https://stackoverflow.com/a/9056395/497756

Unable to install rails. error: You don't have write permissions for the /usr/local/rvm/gems/ruby-2.6.3 directory

That's because at some point you used sudo to install your rvm. So, the system will require sudo permission to install later gems

When you use command $ sudo gem install rails -v 6.0.2.1, you tell system to use normal directly installed ruby, not via rvm, so it warns you No such /user/bin/gem error

The solution for this is to change ownership of all files in the ~/.rvm directory to current account, as if you're using root account by following command

sudo chown -R $USER ~/.rvm

Installing gem fails with permissions error

Use a Ruby version manager, like RVM or rbenv.

I can't speak for rbenv, but RVM prepends a Ruby version-specific bin to your PATH that you have access to, so you don't have to use sudo (which is how you could install gems in your current situation, but is highly discouraged).

rbenv similarly prepends to your $PATH, but it uses a shim.

How to install a gem or update RubyGems if it fails with a permissions error

You don't have write permissions into the /Library/Ruby/Gems/1.8 directory.

means exactly that, you don't have permission to write there.

That is the version of Ruby installed by Apple, for their own use. While it's OK to make minor modifications to that if you know what you're doing, because you are not sure about the permissions problem, I'd say it's not a good idea to continue along that track.

Instead, I'll strongly suggest you look into using either rbenv or RVM to manage a separate Ruby, installed into a sandbox in your home directory, that you can modify/fold/spindle/change without worrying about messing up the system Ruby.

Between the two, I use rbenv, though I used RVM a lot in the past. rbenv takes a more "hands-off" approach to managing your Ruby installation. RVM has a lot of features and is very powerful, but, as a result is more intrusive. In either case, READ the installation documentation for them a couple times before starting to install whichever you pick.

Why do I get write permission errors installing Rails?

The most likely reason you're getting the error:

(Gem::FilePermissionError) You don't have write permissions into the /home/vikas/.rvm/gems/ruby-1.9.2-p320/bin directory. 

Is because, at some point, you used sudo or were running as root when you use RVM to install a gem. When that happened, the ownership of files and/or folders changed to root's permissions, which you can't override running as you.

You don't want to run as root, or use sudo EVER when running rvm or gem commands if you have a RVM installation to provide Ruby in a sandbox in your home directory.

To fix this, try this command:

sudo chown -R vikas ~/.rvm

That will use sudo to change ownership of all files in the ~/.rvm directory to your own account, from the "root" user. This will take at least a few seconds so let it run.

Once that has run, you should be able to switch to each of your Rubies and delete the installed Rails:

rvm use 1.9.2
gem uninstall rails
gem install rails -v 3.2.13

Then:

rvm use 2.0.0
gem uninstall rails
gem install rails -v [whatever version you want]
gem install rails -v

Permission denied error with RVM

I had this same problem and I resolved it by doing the following:

sudo mkdir ~/.gem/specs
sudo chmod 777 ~/.gem/specs

It seems that RVM was trying to create this "specs" folder, but didn't have permissions to do so.

Why do I get a permission denied error while installing a gem?

Your Ruby is installed in /usr/local/Cellar/ruby/....

That is a restricted path and can only be written to when you use elevated privileges, either by running as root or by using sudo. I won't recommend you run things as root since you don't understand how paths and permissions work. You can use sudo gem install jekyll, which will temporarily elevate your permissions, giving your command the rights needed to write to that directory.

However, I'd recommend you give serious thought into NOT doing that, and instead use your RVM to install Ruby into your own home directory, where you'll automatically be able to install Rubies and gems without permission issues. See the directions for installing into a local RVM sandbox in "Single-User installations".

Because you have RVM in your ~/.bash_profile, but it doesn't show up in your Gem environment listing, I suspect you either haven't followed the directions for installing RVM correctly, or you haven't used the all-important command:

rvm use 2.0.0 --default

to configure a default Ruby.

For most users, the "Single-User installation" is the way to go. If you have to use sudo with that configuration you've done something wrong.



Related Topics



Leave a reply



Submit