32

I have installed rvm for multiuser,

when I am doing bundle install, it is giving me error,

linux:/var/rails_apps$ bundle install
ERROR: RVM Ruby not used, run `rvm use ruby` first.        

linux:/var/rails_apps$ rvm use ruby
mkdir: cannot create directory `/usr/local/rvm/log/ruby-2.0.0-p247': Permission denied

I already did,

sudo chmod 777 /var/rails_apps/

Please suggest..

Ashwini
  • 2,449
  • 2
  • 29
  • 42
  • It giving me `sudo: rvm: command not found` error – Ashwini Sep 11 '13 at 09:11
  • You probably installed RVM with sudo. Try this: http://stackoverflow.com/questions/9932125/made-a-mistake-installing-rvm-with-sudo-how-to-reverse – Marek Lipka Sep 11 '13 at 09:12
  • Yes I have installed using rvm with sudo with this cmd `user$ \curl -L https://get.rvm.io | sudo bash -s stable` refered http://rvm.io/rvm/install – Ashwini Sep 11 '13 at 09:15
  • you can not use `sudo` for `rvm use` - sudo changes process and `rvm use` is supposed to change current process environment. – mpapis Sep 11 '13 at 10:29

4 Answers4

90

You have a multiuser installation of rvm - this is not recommended because of the troubles you can get with it (like yours).

Since you are already there this should fix it:

rvmsudo rvm get stable --auto-dotfiles
rvm fix-permissions system

Also make sure you are in rvm group - if not add yourself:

rvm group add rvm $USER

and log in to a new shell (log out and log back in).

Simon
  • 260
  • 1
  • 14
mpapis
  • 52,729
  • 14
  • 121
  • 158
  • 2
    Thanks! For me `rvm fix-permissions` was enough to fix `Permission denied @ rb_sysopen` – Nic Cottrell Mar 02 '16 at 10:09
  • Same for me `rvm fix-permissions system`did the trick, thanks – Rohan Daxini Aug 30 '16 at 09:45
  • 2
    If you only care about permissions for a single user then you can just do `rvm fix-permissions`. Here is the readme for that command: https://github.com/rvm/rvm/blob/master/help/fix-permissions.md – AMB Dec 24 '16 at 16:57
  • 11
    I had to also run `rvm fix-permissions user` in my case, check the link given by @alli – mlabarca May 03 '18 at 14:18
  • 10
    For my ubuntu, what actually worked is: `rvm fix-permissions system; rvm fix-permissions user` – Eric May 08 '20 at 16:17
  • ahh thank you, that was what fixed it for me as well in fedora. – Stephan Aug 11 '23 at 22:22
4

In most of the cases rvm fix-permissions will resolve the problem for single user access but it fails in some cases while making other rvm commands thereafter. So do it with rvmsudo after the fix-permissions command consecutively as

rvm fix-permissions

rvmsudo rvm use ruby
Jaswinder
  • 1,455
  • 14
  • 27
1

For those who may have issues after running the commands shared on every thread out there, try opening ubuntu or the Linux environment you are working with as an administrator.

1 - Search for your app (in my case Ubuntu) using the search bar on the bottom-left of your computer's screen.

2 - if you don't see the option "open as administrator" on the right side, then right-click over the app's icon and you should see it then.

3 - Allow the app to make changes on your computer when prompted and then try the installation commands again.

4 - If that didn't work then try the commands shared in this or other posts, but always as administrator.

Dharman
  • 30,962
  • 25
  • 85
  • 135
0

this command bellow fixed the error on fedora 38 for me:

rvmsudo rvm get stable --auto-dotfiles

rvm fix-permissions system

rvm fix-permissions user
amiben
  • 11
  • 1