Using RVM for multiple users

1,197 views
Skip to first unread message

dubek

unread,
Dec 15, 2009, 11:04:21 AM12/15/09
to rvm (Ruby Version Manager)
I have a machine (Linux) with two users: joe and mary. I want to
install several versions of Ruby, with gems for each version, and I
want all of these versions to be available both for joe and for mary.

As I understand it, RVM uses the home directory of the user, which
prevents this usage.

Note: I don't mind that installing Rubies and gems will require root
permissions.

Thanks in advance,

--
dubek

Wayne E. Seguin

unread,
Dec 15, 2009, 11:46:23 AM12/15/09
to rvm (Ruby Version Manager)
install rvm git head as root (http://rvm.beginrescueend.com/install)
and you can set the default ruby from there and users can use them as
they wish.
As root when you 'rvm use 1.91' 1.9.1 will become the default ruby for
the *entire system* and it's binaries are symlinked into /usr/local/
bin/ so be sure the default system path includes /usr/local/bin

~Wayne.

dreamcat four

unread,
Dec 15, 2009, 1:27:08 PM12/15/09
to rubyversi...@googlegroups.com
Hi,
This is great. Kudos.

$ git clone git://github.com/wayneeseguin/rvm.git
$ cd rvm && sudo ./install

So to be clear:
Is it generally allright to append the source line into system-wide
/etc/bashrc ?

I am asking because the system-wide bashrc is loaded before the user's
individual ~/.bashrc. Wayne, I have yet to notice any i'll effects for
sourcing rvm this early-on. Apart from the user appending to the front
of $PATH, are there any other potential known issues to worry about?


Furthermore, is it correct that:
If some users want to use the system-wide rvm then its best approach
to disable to local one first.

What about the other way around? Ie:
If the user wishes to install their own copy to ~/.rvm and use it in
place of the system-wode copy. Is there a reasonable way to first
unload such a system rvm from their environment? eg clear $rvm_path
and other necessary variables?

Otherwise if the system rvm can just test -f $HOME/.rvm exists
early-on. Before actually sourcing all the /usr/local/rvm/scripts. It
may exit / throw error. Then giving an individual user the capability
to source their own rvm files later on during ~/.bashrc.


Best regards

dreamcat4
drea...@gmail.com
> --
> Please visit http://rvm.beginrescueend.com/ for documentation on rvm.
> Please visit https://www.pivotaltracker.com/projects/26822 to see what is being worked on currently.
>
> You received this message because you are subscribed to the Google
> Groups "rvm (Ruby Version Manager)" group.
> To post to this group, send email to rubyversi...@googlegroups.com
> To unsubscribe from this group, send email to
> rubyversionmana...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/rubyversionmanager?hl=en

Wayne E. Seguin

unread,
Dec 15, 2009, 2:37:54 PM12/15/09
to rvm (Ruby Version Manager)
On Dec 15, 1:27 pm, dreamcat four <dreamc...@gmail.com> wrote:
> Hi,
> This is great. Kudos.
>
> $ git clone git://github.com/wayneeseguin/rvm.git
> $ cd rvm && sudo ./install
>
> So to be clear:
> Is it generally allright to append the source line into system-wide
> /etc/bashrc ?

Yes, this is completely fine. In fact that is how I setup rvm on my
servers. Either that or in the /etc/profile.
rvm sets a 'loaded flag' when it is loaded, if this flag is set it
will not re-load itself so if you 'source rvm' several times it will
only load once.

> I am asking because the system-wide bashrc is loaded before the user's
> individual ~/.bashrc. Wayne, I have yet to notice any i'll effects for
> sourcing rvm this early-on. Apart from the user appending to the front
> of $PATH, are there any other potential known issues to worry about?

Be sure that /usr/local/bin is in the path and first, that way rvm's
selected ruby at the system level becomes the system wide default.
Beware this might change in the near future, the functionality. I am
considering making 'rvm use X' the same in root and user shells and
changing
'rvm X --default' when done as root to create the symlinks as I
believe it will feel more natural than the current 'using as root
switches the system ruby'.

... Actually give me a few minutes...

I just released rvm 0.0.95 which has this behavior as default now (eg
'rvm X --default' as root now sets the default system ruby).

> Furthermore, is it correct that:
> If some users want to use the system-wide rvm then its best approach
> to disable to local one first.

Users can safely remove their ~/.rvm/ directory and use the system
wide install if they desire.
If there are any issues with that please lmk.
Additionally the users can keep their ~/.rvmrc file and it will
override the /etc/rvmrc file settings.
They need only change where rvm is sourced in their profiles.

> What about the other way around? Ie:
> If the user wishes to install their own copy to ~/.rvm and use it in
> place of the system-wode copy. Is there a reasonable way to first
> unload such a system rvm from their environment? eg clear $rvm_path
> and other necessary variables?

sudo rm -rf /usr/local/rvm/ /usr/local/bin/rvm
<<install in user account>>

Although that might be doing too much since if you have a user level
install it will simply ignore the system install.

> Otherwise if the system rvm can just test -f $HOME/.rvm exists
> early-on. Before actually sourcing all the /usr/local/rvm/scripts. It
> may exit / throw error. Then giving an individual user the capability
> to source their own rvm files later on during ~/.bashrc.

rvm loads user then system when installed as user...


~Wayne

Dov Murik

unread,
Dec 16, 2009, 7:23:28 AM12/16/09
to rubyversi...@googlegroups.com
Thanks.

2009/12/15 Wayne E. Seguin <waynee...@gmail.com>
>
> >
> > $ git clone git://github.com/wayneeseguin/rvm.git
> > $ cd rvm && sudo ./install
> >
> > So to be clear:
> > Is it generally allright to append the source line into system-wide
> > /etc/bashrc ?
>
> Yes, this is completely fine. In fact that is how I setup rvm on my
> servers. Either that or in the /etc/profile.

Let me just make sure this answers my scenario:

1. I install rvm as root
2. I install ruby 1.8.6, 1.8.7 and 1.9.1 with rvm as root

Now:

joe can use 1.8.6 for program-A and 1.8.7 for program-B and 1.9.1 for
program-C (which may all start at the same time), and same for mary
(running at the same time).

The reason I'm asking about this scenario is that I have several
programs (scripts?) running on my server (under multiple users), and I
want to migrate them to newer Ruby versions one-by-one. So I'll keep
all my current scripts running 1.8.6, and slowly test one script at a
time with a newer ruby.

Thanks again for your help,

dubek

Wayne E. Seguin

unread,
Dec 16, 2009, 4:30:11 PM12/16/09
to rubyversi...@googlegroups.com, Wayne E. Seguin
On Dec 16, 2009, at 07:23 , Dov Murik wrote:
> 2009/12/15 Wayne E. Seguin <waynee...@gmail.com>
> Let me just make sure this answers my scenario:
>
> 1. I install rvm as root
> 2. I install ruby 1.8.6, 1.8.7 and 1.9.1 with rvm as root
>
> Now:
>
> joe can use 1.8.6 for program-A and 1.8.7 for program-B and 1.9.1 for
> program-C (which may all start at the same time), and same for mary
> (running at the same time).

Yes.

> The reason I'm asking about this scenario is that I have several
> programs (scripts?) running on my server (under multiple users), and I
> want to migrate them to newer Ruby versions one-by-one. So I'll keep
> all my current scripts running 1.8.6, and slowly test one script at a
> time with a newer ruby.

Using rvm as stated above this will work.

You can even override the system installation on a per-user basis leaving a pre-existing system ruby intact and doing everything in userland only.

~Wayne

~~~~~~~~~~~~~~~~~~~~
Wayne E. Seguin
Founding Member, 1/3 / 0
Division by Zero, LLC
wa...@overnothing.com
~~~~~~~~~~~~~~~~~~~~




dreamcat four

unread,
Dec 20, 2009, 6:19:07 PM12/20/09
to rubyversi...@googlegroups.com, Wayne E. Seguin
Hi again, 2 points.

1)
I noticed that this system-wide install doesn't care for overiding the
default $rvm_path in /etc/rvmrc to some alternative path. Ie setting
up the rvmrc file prior to installation. Let's say we wanted to
install rvm into `/opt/rvm` instead of the usual places in /usr/local.
And we also want to override the rvm symlink path of /usr/local/bin to
some other path.

We must add these steps....

/etc/rvmrc:
rvm_path=/opt/rvm
rvm_symlink_path=/opt/bin
EOF

# Create these 2 directories before running the rvm install script
$ mkdir -p /opt/rvm
$ mkdir -p /opt/bin

# Then do what we normally do
$ gem install rvm
$ sudo rvm-install

The command output was:

rvm - shell scripts that allows a user to manage multiple ruby
versions in their own account.

Prepairing /opt/rvm ...

Installing rvm to /opt/rvm/ ...

Installing bin scripts to /opt/rvm/bin ...

Checking rc files (/etc/profile /etc/zshenv) ...
Adding 'if [[ -s /opt/rvm/scripts/rvm ]] ; then source
/opt/rvm/scripts/rvm ; fi' to /etc/profile.
Adding 'if [[ -s /Users/id/.profile ]] ; then source /Users/id ;
fi' to /etc/zshenv.
Adding 'if [[ -s /opt/rvm/scripts/rvm ]] ; then source
/opt/rvm/scripts/rvm ; fi' to /etc/zshenv.

Symlinking rvm to /opt/bin/rvm ...

Seems to be a successful installation. Perhaps the rvm install script
can include the missing steps.

2)
There may be a small bug somewhere. You probably didn't want to
reference $HOME in /etc/zshrc.

This bit:
Adding 'if [[ -s /Users/id/.profile ]] ; then source /Users/id ;
fi' to /etc/zshenv.

Should be:
Adding 'if [[ -s /opt/rvm/scripts/rvm ]] ; then source
/opt/rvm/scripts/rvm ; fi' to /etc/zshenv.


dreamcat4
drea...@gmail.com

Wayne E. Seguin

unread,
Dec 20, 2009, 6:31:37 PM12/20/09
to rubyversi...@googlegroups.com, Wayne E. Seguin

Yes symlink_path != install path so that makes sense. Yes we can add more information to the installer and the mkdir commands.

>
>
> 2)
> There may be a small bug somewhere. You probably didn't want to
> reference $HOME in /etc/zshrc.
>
> This bit:
> Adding 'if [[ -s /Users/id/.profile ]] ; then source /Users/id ;
> fi' to /etc/zshenv.
>
> Should be:
> Adding 'if [[ -s /opt/rvm/scripts/rvm ]] ; then source
> /opt/rvm/scripts/rvm ; fi' to /etc/zshenv.

Thank you for pointing this out, I'll fix it tonight in git head.

~Wayne

Wayne E. Seguin

unread,
Dec 20, 2009, 7:06:24 PM12/20/09
to rubyversi...@googlegroups.com, Wayne E. Seguin

On Dec 20, 2009, at 18:31 , Wayne E. Seguin wrote:
>> 2)
>> There may be a small bug somewhere. You probably didn't want to
>> reference $HOME in /etc/zshrc.
>>
>> This bit:
>> Adding 'if [[ -s /Users/id/.profile ]] ; then source /Users/id ;
>> fi' to /etc/zshenv.
>>
>> Should be:
>> Adding 'if [[ -s /opt/rvm/scripts/rvm ]] ; then source
>> /opt/rvm/scripts/rvm ; fi' to /etc/zshenv.
>
> Thank you for pointing this out, I'll fix it tonight in git head.
>
> ~Wayne

On further inspection the .profile one *is* intended (fixes a bug some users have reported) however I have switched it as you suggest from zshrc to zshenv.

~Wayne

Reply all
Reply to author
Forward
0 new messages