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.
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)
So I looked at what was actually available in pre-built binaries:
And modified my install to ask for the latest precompiled version
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.
Hmm.. why not create an EBS AMI with RVM and the Ruby versions and launch it anytime you want? Just a thought.:)
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) forrvm_path
,rvm_prefix
,rvm_bin_path
andrvm_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.
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.
In recent versions of RVM, you can pass in the
--binary
optionYou can find a full list of available binaries with
rvm list remote