19

I'm confused about whether, on a server, you're supposed to install RVM as a regular user or do a system-wide installation, and, if the latter, how you're supposed to do things like bundle install without using sudo.

Is there any definite set of guidelines on what you're supposed to do as far as RVM is concerned on a server running Rails under e.g. Passenger and Nginx? In this type of environment, not all Ruby processes run under the same user, so I think that's where things get unclear as far as RVM and bundler are concerned.

How about just avoiding RVM all together on the server and just installing Ruby and gems the old fashioned way there? Is that preferable if you can get away with it?

dan
  • 43,914
  • 47
  • 153
  • 254

3 Answers3

6

You could install RVM as a regular user, although I don't see the point. Bundler is per-application and doesn't need sudo privileges since it can install your gems into a bundle directory that the bundle install user can access with, for instance:

bundle install --deployment

which will put them in vendor/bundle by default.

I think of RVM as a development tool for managing multiple ruby versions. On deployment machines I tend to either use system Ruby or install from source.

Rein Henrichs
  • 15,437
  • 1
  • 45
  • 55
4

I would highly recommend doing a system-wide install for a production environment. Running user-specific RVMs just seems like a huge hassle. I use Passenger/Nginx in production and each project has its own users. All I have to do is add them to the rvm group and I'm good to go.

Jim Mitchener
  • 8,835
  • 7
  • 40
  • 56
  • Got a guide anywhere? I tried using a system-wide install for production and had separate rubies and gemsets for each project. However, it was a pain to configure Nginx/Passenger to use the right ruby/gemset. I also found that commands such as setting the default ruby/gemset `rvm use ree@gemset --default` affected the whole system, regardless of the user I was logged in as. Another question: Do you also use .rvmrc files for each project? – John Jul 22 '11 at 13:42
  • 1
    I always create a `setup_load_paths.rb` as per https://rvm.beginrescueend.com/integration/passenger/ – Jim Mitchener Jul 22 '11 at 17:06
  • Thanks for the response, jcm. Does that method require `MY_RUBY_HOME` to be set up as an environment variable for each project/user? – John Jul 25 '11 at 16:17
3

RVM may be installed as super user. While it doesn't need to be, there are a lot of advantages to doing so (especially on a multi-user system). Any commands that come with Ruby (and associated Ruby Gems) should have their permissions set correctly to be run appropriately. Bundle does not require super user access to be used. It can run under a particular user, just as gem install can be local to a user or system wide when done with a full sudo.

RVM only manages your particular installs of Ruby, so that you can develop on multiple levels of Ruby- From RMI 1.8 and 1.9 to JRuby 1.6, et cetera. You may have different projects you are working on, and therefore need differing needs per project.

As far as on a server itself goes (assuming it's an external facing server with some kind of content on it), that just depends on the system administrators really. The use case changes somewhat. If you only need Ruby 1.9 on the server, there's really no need for RVM. Because managing multiple versions of Ruby is not required. So I would take that in to account when you decide whether to go system wide on a server itself.

Hope that helps!

Christopher WJ Rueber
  • 2,141
  • 15
  • 22
  • 3
    It is actually NOT recommended to be installed as root for most purposes. I never do a root install for development machines. It's much nicer having a self-contained `~/.rvm` for a single user system. – Jim Mitchener Apr 05 '11 at 23:25
  • That's more of a preference than a requirement. It's extremely useful to have it available to all users for other reasons. For example, if I want to mimic my production environment more closely with another user, I don't have to go through the pain of reinstalling RVM under yet another user. Depends on how you're used to working. – Christopher WJ Rueber Apr 05 '11 at 23:29
  • 1
    "RVM is meant to be installed as super user." Wrong. Its initial goal was a user sandbox for development. It has developed the ability to be used system wide, but its primary strength is still as a user's sandbox. With 1.5+ it has changed more; The docs are in transition according to Wayne's comment here a coupl'a weeks ago. – the Tin Man Apr 05 '11 at 23:32
  • @Tin Man- Fair argument. I'll give you that. I have altered my answer accordingly. – Christopher WJ Rueber Apr 05 '11 at 23:34
  • 1
    "If you are installing for development or most purposes, the recommended installation method is installing into a user's home directory completely self contained." from the RVM install guide. – Jim Mitchener Apr 05 '11 at 23:36
  • @jcm- Still an opinion. The question was asking for a definite set of guidelines. Which there is not. – Christopher WJ Rueber Apr 05 '11 at 23:37