[rvm] install rubies as root and use them as a user

1,108 views
Skip to first unread message

hiroshi

unread,
Apr 16, 2010, 8:03:05 AM4/16/10
to rvm (Ruby Version Manager)
hi,

I'd like to install rubies as root and "rvm use" as a user.
I figured out a way that installing rvm by both root and each user and
symlinking root installed rubies into user's .rvm directories like
that:
sudo rvm install ruby-1.9.2
(cd ~/.rvm/rubies && ln -s /usr/local/rvm/rubies/ruby-1.9.2-preview1
ruby-1.9.2-preview1)
(cd ~/.rvm/bin && ln -s /usr/local/rvm/bin/ruby-1.9.2-preview1
ruby-1.9.2-preview1)
(cd ~/.rvm/gems && ln -s /usr/local/rvm/gems/ruby-1.9.2-preview1
ruby-1.9.2-preview1)

After that, as a user I can:
rvm use ruby-1.9.2

If a gem is needed:
rvmsudo gem install bundler

Is it a right way to share root installed rvm rubies with users?
That symlinking all over and duplicated installation of rvm feel me
something wrong.
# I think symlinking rvm/rubies, bin gems will work, but it may
prevent users install own local rubies.

(I use rvm 0.1.27 via `sudo gem install rvm`)

Thanks

--
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,
Apr 16, 2010, 11:17:55 AM4/16/10
to rubyversi...@googlegroups.com
On Fri, Apr 16, 2010 at 8:03 AM, hiroshi <hiros...@gmail.com> wrote:
> hi,
>
> I'd like to install rubies as root and "rvm use" as a user.
> I figured out a way that installing rvm by both root and each user and
> symlinking root installed rubies into user's .rvm directories like
> that:
> sudo rvm install ruby-1.9.2
> (cd ~/.rvm/rubies && ln -s /usr/local/rvm/rubies/ruby-1.9.2-preview1
> ruby-1.9.2-preview1)
> (cd ~/.rvm/bin && ln -s /usr/local/rvm/bin/ruby-1.9.2-preview1
> ruby-1.9.2-preview1)
> (cd ~/.rvm/gems && ln -s /usr/local/rvm/gems/ruby-1.9.2-preview1
> ruby-1.9.2-preview1)
>
> After that, as a user I can:
> rvm use ruby-1.9.2
>
> If a gem is needed:
> rvmsudo gem install bundler

Very creative! I recommend against doing this.

Additionally, I recommend using 1.9.2-head instead of preview1
as it has far less bugs / pain points.

> Is it a right way to share root installed rvm rubies with users?
> That symlinking all over and duplicated installation of rvm feel me
> something wrong.
> # I think symlinking rvm/rubies, bin gems will work, but it may
> prevent users install own local rubies.
>
> (I use rvm 0.1.27 via `sudo gem install rvm`)

If you *must* install your rubies as root, then to share them for each user
set the following in each user's ~/.rvmrc file:

export rvm_gems_path="$HOME/.rvm/gems/"

Additionally, each user will have to source rvm slightly different from normal
at the end of their profiles (~/.bashrc / ~/.bash_profile):

source /usr/local/rvm/scripts/rvm

Users can then do 'gem install X' without needing sudo permissions and
use their own gemsets, etc. The restriction would be that they would not

~Wayne

hiroshi saito

unread,
Apr 16, 2010, 12:24:55 PM4/16/10
to rubyversi...@googlegroups.com
Wayne,

> Additionally, I recommend using 1.9.2-head instead of preview1
> as it has far less bugs / pain points.
Yeah, I switched after seeing "[BUG] rb_add_method: unsupported method
type (8)" ;)

To be clear why I prefer to share root installed rubies and gems.
I have a small server which (will) hosts several rails apps dependent
on different version of rubies. (Yeah, I should use one ruby for a
server, but...)
I seldom maintain those apps on the server as a user. It seems natural using
same set of ruby and gems (at least for me).

Anyway,
after a while I posted, I found an improved way as you mentioned of .rvmrc.
My version of .rvmrc is:

rvm_rubies_path=/usr/local/rvm/rubies
rvm_gems_path=/usr/local/rvm/gems

with this settings and an extra process I got root installed rubies as a user.
The extra process is
(cd ~/.rvm/bin && ln -s /usr/local/rvm/bin/ruby-head ruby-head)

just after
rvmsudo rvm install ruby-head
.

I rather content with the result of it, but if you ask me what cause
the last symlink.

At a line of the file rvm/script/symlink;

ln -fs "$rvm_bin_path/$rvm_ruby_string" "$rvm_bin_path/${flag}_ruby"
for binary in gem irb rake ; do
ln -fs "$rvm_ruby_home/bin/${binary}" "$rvm_bin_path/${flag}_${binary}"
done

Why not:

for binary in ruby gem irb rake ; do
ln -fs "$rvm_ruby_home/bin/${binary}" "$rvm_bin_path/${flag}_${binary}"
done

Anyway, thanks for the greatness of RVM!
--
齋藤 宏
Hiroshi Saito
hiros...@gmail.com
http://blog.yakitara.com/
http://github.com/hiroshi
http://www.linkedin.com/pub/hiroshi-saito/8/aab/260

Wayne E. Seguin

unread,
Apr 16, 2010, 2:40:58 PM4/16/10
to rubyversi...@googlegroups.com
On Fri, Apr 16, 2010 at 12:24 PM, hiroshi saito <hiros...@gmail.com> wrote:
> Wayne,
>
>> Additionally, I recommend using 1.9.2-head instead of preview1
>> as it has far less bugs / pain points.
> Yeah, I switched after seeing "[BUG] rb_add_method: unsupported method
> type (8)" ;)
>
> To be clear why I prefer to share root installed rubies and gems.
> I have a small server which (will) hosts several rails apps dependent
> on different version of rubies. (Yeah, I should use one ruby for a
> server, but...)
> I seldom maintain those apps on the server as a user. It seems natural using
> same set of ruby and gems (at least for me).

That's fine :)

> Anyway,
> after a while I posted, I found an improved way as you mentioned of .rvmrc.
> My version of .rvmrc is:
>
>  rvm_rubies_path=/usr/local/rvm/rubies
>  rvm_gems_path=/usr/local/rvm/gems
>
> with this settings and an extra process I got root installed rubies as a user.
> The extra process is
>  (cd ~/.rvm/bin && ln -s /usr/local/rvm/bin/ruby-head ruby-head)
>
> just after
>  rvmsudo rvm install ruby-head
> .
> I rather content with the result of it, but if you ask me what cause
> the last symlink.
>
> At a line of the file rvm/script/symlink;
>
>  ln -fs "$rvm_bin_path/$rvm_ruby_string" "$rvm_bin_path/${flag}_ruby"
>  for binary in gem irb rake ; do
>    ln -fs "$rvm_ruby_home/bin/${binary}" "$rvm_bin_path/${flag}_${binary}"
>  done
>
> Why not:
>
>  for binary in ruby gem irb rake ; do
>    ln -fs "$rvm_ruby_home/bin/${binary}" "$rvm_bin_path/${flag}_${binary}"
>  done

Due to the fact that the one in bin_path is actually a wrapper script
which sets environment...

I am now wondering if that is necessary at this point...


> Anyway, thanks for the greatness of RVM!

Enjoy!
Reply all
Reply to author
Forward
0 new messages