Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm using EC2 and sometimes launch servers that I want to use only for a short time. Usually I want to install some version or versions of Ruby on them, and for this RVM is very convenient -- if it wasn't for the fact that it takes forever to compile Ruby. It's really boring to have to wait almost half an hour just for Ruby to compile when the rest of the server setup is done in minutes. It completely kills the cloud computing experience.

Is there a way to get the convenience of RVM without the inconvenience of compiling each Ruby version for every new server I launch? Can I precompile a Ruby version and keep it somewhere accessible, and then have RVM use that instead of compiling it from source? Can I simply archive some directory under the RVM root dir after I've installed a Ruby version, save it somewhere and then extract it in the right place on the next server I launch? In that case, which files and directories do I need to keep?

I want to use RVM not only to be able to switch between Ruby versions, but also because it allows me to keep separate gemsets for different applications, so not using RVM would be very inconvenient.

All servers have the same OS and architecture, Ubuntu 10.04, 32 bit.

share|improve this question

4 Answers 4

up vote 0 down vote accepted

If you roll up and deploy your pre-configured ~/.rvm folder and make sure the remote .bashrc is configured to use it, do you get any problems? From what I can tell, rvm is designed to allow you to do this.

The only snags I imagine could be around making sure you have the right gems and packages in place to allow your code to run. But then, you'd prepare your .rvm on the target platform right? Also, take into account any OS packages required by your ruby environment.

share|improve this answer

Probably a bit long in the tooth now, but as of 1.16 rvm supports downloading pre-compiled binaries.

I was having difficulty when I asked for the head version (ie 1.9.3)

20130212 00:31:00 dev@domU-xxxx:~ rvm install 1.9.3
Searching for binary rubies, this might take some time.
No binary rubies available for: ubuntu/12.04/i386/ruby-1.9.3-p385.
Continuing with compilation. Please read 'rvm mount' to get more information on binary rubies.

So I looked at what was actually available in pre-built binaries:

20130212 00:31:27 dev@domU-xxxx:~ rvm list remote

# Rubies available for 'ubuntu/12.04/i386':

   ruby-1.9.3-p194
   ruby-1.9.3-p286
   ruby-1.9.3-p327
   ruby-1.9.3-p362
   ruby-1.9.3-p374
   ruby-2.0.0-rc1

And modified my install to ask for the latest precompiled version

20130212 00:34:25 dev@domU-xxxx:~ rvm install 1.9.3-p374
Searching for binary rubies, this might take some time.
ruby-1.9.3-p374 - #configure
ruby-1.9.3-p374 - #download
######################################################################## 100.0%
ruby-1.9.3-p374 - #validate archive
ruby-1.9.3-p374 - #extract
ruby-1.9.3-p374 - #validate binary
ruby-1.9.3-p374 - #setup
Saving wrappers to '/home/dev/.rvm/bin'.
ruby-1.9.3-p374 - #importing default gemsets, this may take time ...
20130212 00:35:59 dev@domU-xxxxx:~

As you can see this took less than 2 minutes to run (as opposed to the 15-20 minutes it takes to compile on an EC2 small instance). Hope this helps someone else with the same problem.

share|improve this answer

Hmm.. why not create an EBS AMI with RVM and the Ruby versions and launch it anytime you want? Just a thought.:)

share|improve this answer
1  
That doesn't really work for me. The servers are not all the same, it's not always the same version of Ruby, and I'd rather not create an image with all possible versions. –  Theo Oct 30 '10 at 12:21

If you didn't want to keep using RVM, then maybe you would want to use ruby-enterprise's binary packages? I'm using it not just because it's a lot faster to install, but also because of the horribly done packages in Ubuntu/Debian currently.

So there are binary packages for Ubuntu and I'm sure that beyond the latest version, they also let you download previous version, etc..

Check it out: http://www.rubyenterpriseedition.com/download.html#ubuntu

The only problem is that this will probably not allow you to switch back and forth between ruby installations on the same instance. I'm not sure if that is something you absolutely require.

But other than that, it would be simple to script uninstall and install it either in bash or maybe with a chef recipe. But of course that's not as convenient as rvm.

Edit:

If you can't use the REE .deb, the easiest would be to create an EBS-based AMI and include a rvm install along with your most used ruby versions. That's only one solution to the problem.

Another solution would be to check /etc/rvm (assuming system-wide-install) for rvm_path, rvm_prefix, rvm_bin_path and rvm_man_path and getting those files and downloading them on an instance when you launched it.

This process could be automated with a small shell script that you pass to the EC2 instance (see user-data) when you start it up.

As a general measure, I'd also check into passing custom ./configure flags to rvm when you build additional ruby versions to maybe speed up the compilation. I'm not exactly sure, but I bet you can save them into a .rvm file or similar.

The alternative to above is get a more beefy instance but that may not work out in the long run as the associated costs to run one are also higher.

share|improve this answer
    
As I mentioned in the question I need different versions of Ruby, and I want the convenience of gemsets, so using only REE is not an option. There are binary packages of most versions of Ruby, but it's a mess to handle yourself. –  Theo Oct 30 '10 at 16:07
    
Can you share how you use rvm? E.g. rvm install ree? –  Till Oct 30 '10 at 16:33
    
Been looking at the docs for a bit, all of this will be compiled. I guess the problem is that due to its very custom nature it's hard to offer binaries in this case. E.g. binary packages on Ubuntu follow a distinct layout -- e.g. REE, they install to /usr/local and you can't change. –  Till Oct 30 '10 at 16:40
    
Extended my answer. –  Till Oct 30 '10 at 16:50
    
Ruby Enterprise Edition is no longer active –  sleepycal Apr 30 at 19:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.