Can I use RVM to maintain a single version of Ruby

2019-05-02 12:05发布

问题:

I love RVM. I realize that the main use case for it is letting different users switch between different versions of Ruby. But let's say I'm deploying a Rails app to a server and I just want a single version of Ruby running. In particular, I want 1.9.2, which is a breeze to install with RVM but a pain without it. Is there a way that I can say "I want this to be the canonical Ruby installation for all users" (along with all of its gems) without having to create a bunch of symlinks by hand and change them every time I update to a newer Ruby release?

回答1:

Install RVM as root and do a sudo rvm use 1.9.2 --default. Any user sourcing /usr/local/rvm/scripts/rvm will per default have 1.9.2.



回答2:

I know this doesn't quite answer your question, but:

I ran into several problems with installing RVM globally and resorted to using one user account for deployment and for all Ruby / Rails processes -- that users account exists on all dev and production servers, and the .rvm directory is rsync'ed from one dev-server to all other servers.

How many different users on your App servers do really need to access Ruby 1.9.2? Can't you just trim that down to just one user? That worked best for me.

Note:

One thing you probably want to avoid is to install RVM on your app server(s) manually and then install Ruby and Gems on the app server ... you don't want to keep tools like cc lying around on your production servers for security reasons! rsync'ing the .rvm directory is far safer! and the result is far more consistent!