4

I'm trying to install RVM into /usr/local/rvm because I need the ability to run ruby as a server. However, whenever I run:

bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)

it defaults to my home directory, /home/<user>/.rvm.

I've tried running:

sudo bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)

as well as enabling the Ubuntu root password and logging in with the root account, but the install always defaults to my home directory. How can I fix this, or would it be easier to just install Ruby from source?

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Alex Mullans
  • 1,699
  • 2
  • 17
  • 34
  • according to https://rvm.beginrescueend.com/rvm/install/ if you run it as root, it should install in /usr/local/rvm ... – DGM Jun 08 '11 at 19:58

5 Answers5

1

In my opinion, RVM on a production host isn't as useful as it is for a developer's sandbox. I think RVM is a great tool but it isn't for every situation.

Developers need a lot of flexibility for using different versions of Ruby, and for using specific versions of gems. RVM shines for that. It makes it easy to switch automatically, to test against all versions of Ruby installed, or, if things go haywire, to blow it all away and start over quickly.

In a production server environment, where you generally dedicate a host to a particular service, or a set of related services, the need to quickly switch between various Rubies and gem sets tends to disappear. I put only one version of Ruby on mine. All apps point at it. IF I needed more than one, I'd install it into a separate /opt or /local directory hierarchy, and set my PATH for the owning account to point to the needed version. In production that's usually a set once and forget situation.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
  • The way you do it still takes more effort than just using rvm. It's quite possible to need multiple rubies - at one point I needed to run redmine on 1.8.7 and my rails app on 1.9.2. rvm made the install a snap. – DGM Jun 08 '11 at 19:52
  • Like @DGM mentioned, I also would prefer the easier rvm management than the manual installation of rubies (and not to have the ability of different gemsets), if/when I have a machine with more than one app running on it. / rvm is not only for developers, it's the neatest ruby tool I've ever seen. – asaaki Jun 09 '11 at 01:13
  • 3
    Kinda bugs me that this answer was accepted, it doesn't answer the actual question. – DGM Jun 09 '11 at 12:39
  • It answers the question "would it be easier to just install Ruby from source?"... which it was. If you have an answer as to how I can make RVM on Ubuntu perform a multi-user install, I'd love to give it a shot. – Alex Mullans Jun 09 '11 at 14:35
  • Installing Ruby from source is not difficult, though some Linux distributions need a bit of prepping before they're ready. For Ubuntu it's a wash between installing RVM and letting it install Ruby, or installing Ruby from source. Now, let's talk about installing Ruby 1.9.2 on old CentOS vs. using RVM when neither has the necessary dependencies in a restricted environment where the host can't see the internet... I've done it and it was ugly. :-) – the Tin Man Jun 09 '11 at 18:42
  • 1
    While I don't know whether it's production ready, the creator of RVM states that he designed it for production, and being used for developers was an added bonus: http://stackoverflow.com/questions/5864001/is-rvm-production-ready/6282260#6282260 – Andrew Grimm Jun 17 '11 at 00:11
1

You can install rvm in multi-user mode on Ubuntu. The instructions are the same as for other systems, as described here http://beginrescueend.com/rvm/install/ Just install it using sudo.

However, there is a different issue with Ubuntu that will fail subsequent commands like sudo rvm install 1.9.2 because of the way Ubuntu implement the sudo command. On ubuntu, sudo changes the path by default, to make it more secure. This earlier thread discusses the issue in detail sudo changes PATH - why?

To workaround this problem, edit your sudoers file with visudo and add specify

Defaults !secure_path

as suggested on the related thread.

Community
  • 1
  • 1
Shyam Habarakada
  • 15,367
  • 3
  • 36
  • 47
  • It should be noted that if the multi-user (systemwide) installation was executed properly (by running it using `sudo`), any users belonging to the rvm group shouldn't need to use `sudo` with any RVM commands, unless upgrading the RVM installation, in which case you would use `rvmsudo` in order to carry the environment over (which `sudo` does not do by default). – clpo13 Sep 05 '12 at 21:12
0

When you are logged in as root check if rvm_path is set:

echo $rvm_path

If it is, then:

export rvm_path=
rm /etc/rvmrc

This should be enough.

Oben Sonne
  • 9,893
  • 2
  • 40
  • 61
ishi
  • 1
0

To be sure, try sudo su -c bash < <(...). You can use sudo without having a root user account on the system (that's how OSX was configured when I bought it), so you should be careful with sudo. Also, for example, sudo su -c env has a different path than sudo env in my Ubuntu install.

Also, note that after the install (you can't sudo a function) you need to use rvmsudo rvm ... instead of sudo rvm ... if you aren't logged in as root (i.e. maybe you should sudo su then do your work).

bias
  • 1,467
  • 3
  • 19
  • 39
0

Instead of running commands with sudo or enabling the root password, try this:

$ sudo su -

This will switch you to the root account where you can run the install command:

# bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)

That worked for me.