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

1.6k Views Asked by At

I installed ruby 2.6.3 using RVM. later when i try to install rails i am getting following error.

$ gem install rails -v 6.0.2.1

ERROR: While executing gem ... (Gem::FilePermissionError) You don't have write permissions for the /usr/local/rvm/gems/ruby-2.6.3 directory.

$ sudo gem install rails -v 6.0.2.1

sudo: unable to execute /usr/bin/gem: No such file or directory

1

There are 1 best solutions below

3
quyetdc On BEST ANSWER

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