nobody
nobody

Reputation: 8263

How do I use a single-user's RVM installation globally?

I have RVM installed on a machine under a single users account on an Ubuntu 10.04 machine, and I want to give the other users of this machine access to that same install.

Is there a way to do this?

Upvotes: 0

Views: 822

Answers (2)

mpapis
mpapis

Reputation: 53158

In case of binary rubies it should be possible to just move RVM.

Check not movable rubies

You can find if there are any not movable rubies with

rvm all --verbose do rvm config-get configure_args | grep -v -- '--enable-load-relative'

In my case it is (just few):

jruby-1.7.3: jruby 1.7.3 (1.9.3p385) 2013-02-21 dac429b on OpenJDK 64-Bit Server VM 1.7.0_21-b02 [linux-amd64] 

rbx-head: rubinius 2.0.0.rc1 (1.8.7 bed7e913 yyyy-mm-dd JI) [x86_64-unknown-linux-gnu] 

ruby-1.8.7-p374: ruby 1.8.7 (2013-06-27 patchlevel 374) [x86_64-linux] 
 '--prefix=/home/mpapis/.rvm/rubies/ruby-1.8.7-p374' '--disable-install-doc' '--enable-shared' 'CC=ccache gcc' 'CFLAGS=-O3 -O2 -fno-tree-dce -fno-optimize-sibling-calls'
ruby-1.9.3-p448: ruby 1.9.3p448 (2013-06-27 revision 41675) [x86_64-linux] 
 '--prefix=/home/mpapis/.rvm/rubies/ruby-1.9.3-p448' '--disable-install-doc' '--enable-shared' 'CC=ccache gcc'
ruby-2.0.0-p247: ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux] 

For those rubies that have flags you need to either remove them or reinstall after RVM is moved, in this case this are: 1.8.7 and 1.9.3.

Moving RVM

It should be as easy as:

sudo mv ~/.rvm /usr/local/rvm
__rvm_switch /usr/local/rvm

Simulate installation (to generate shell initialization entries for system installation:

rvmsudo rvm get stable --auto-dotfiles

Now for every user that should be able to use RVM add them to rvm group:

rvmsudo rvm group add rvm $USER

Repeat it for every user replacing $USER with the user name.

Reinstalling not movable rubies

For rubies found in first step run:

rvm reinstall ruby-1.8.7-p374,ruby-1.9.3-p448

Cleaning

The user account that installed RVM in first place will have old initialization code, you can find it with:

grep -n rvm ~/.profile ~/.bashrc ~/.bash_profile ~/.bash_login ~/.zshenv ~/.zprofile ~/.zshrc ~/.zlogin

This will show the lines that contain RVM, open this files in your favorite editor and remove them.

Upvotes: 2

the Tin Man
the Tin Man

Reputation: 160553

I seriously doubt it's worth trying to convert a single user's installation to multiple-user.

During the installation of a unique Ruby, its path is compiled into components. That will be remembered and would have to be changed.

I think it would be much easier to install using the multi-user method and reload the needed gems. It might take a couple hours if you have multiple Rubies and a lot of gems, but that's a lot better than weeks of debugging weird errors.

Upvotes: 0

Related Questions