rvm on machine with no net access?

3,744 views
Skip to first unread message

Korny Sietsma

unread,
Jul 21, 2010, 1:36:10 AM7/21/10
to rubyversi...@googlegroups.com
Hi folks - just looking for ideas here.
We use rvm in development, and I'd quite like to run it on a managed server.
However, the IT policy here is that managed servers have no internet access.  I am trying to modify this policy to allow for calling external APIs etc., but I doubt it will ever change for installing software - the fundamental assumption is that production systems are built from local, managed resources - satellite servers, locally installed packages, etc.

Is there some way to set up rvm on a server *with* net access, download all the dependencies for your ruby versions (source code, gems, etc) and then tar up the whole shebang and deploy it to a different server, and rebuild the rubies/gems once there?

Note that our net-visible machines typically are not the same OS as the managed servers - for a start, devs run Ubuntu whereas production is either Solaris or RHEL.  :-/

[update] I found the post by Steve Haddox describing RVM:FW (http://github.com/stevenhaddox/rvm_fw) - it looks like it might cover what I need, but it's a bit unclear how it actually works, and it doesn't look like it'll do gemsets.  But it might be a start.  Though for my purposes, all I really need is a way to clone a functioning rvm setup, and recompile the binaries in the cloned system.

- Korny

--
Kornelis Sietsma  korny at my surname dot com
kornys on twitter/fb/gtalk/gwave www.sietsma.com/korny
"Every jumbled pile of person has a thinking part
that wonders what the part that isn't thinking
isn't thinking of"

Chad Woolley

unread,
Jul 21, 2010, 11:14:57 AM7/21/10
to rubyversi...@googlegroups.com
On Tue, Jul 20, 2010 at 10:36 PM, Korny Sietsma <ko...@sietsma.com> wrote:
> Hi folks - just looking for ideas here.
> We use rvm in development, and I'd quite like to run it on a managed server.
> However, the IT policy here is that managed servers have no internet access.
>  I am trying to modify this policy to allow for calling external APIs etc.,
> but I doubt it will ever change for installing software - the fundamental
> assumption is that production systems are built from local, managed
> resources - satellite servers, locally installed packages, etc.

Set up an ssh tunnel. BOFH's deserve to be circumvented.

Or, if you are too nice for that, set up an internal server with a gem
server for all your gems, ruby, and RVM itself, then point to that. I
think all of these URLs should be configurable in RVM? If not, it
should be easily hackable, and you can can make it configurable and
contribute the patch.

-- Chad

Korny Sietsma

unread,
Jul 26, 2010, 9:16:26 PM7/26/10
to rubyversi...@googlegroups.com
Hi folks - replying to self in case someone else sees this thread :)

It turns out to be not too painful, though it's pretty hacky, to clone an rvm deployment to another machine sans internet:

1. Build a clean local rvm with all the rubies and gems you want installed.
2. tar/gzip or whatever, the ~/.rvm file, copy and untar it on your remote server in the same directory
3. log in to the server
4. add the rvm loader magic to your .bashrc:
  if [[ -s /home/bofh/.rvm/scripts/rvm ]] ; then source /home/bofh/.rvm/scripts/rvm ; fi
5. reload bashrc
6. uninstall all installed rubyies - "rvm uninstall ruby-1.9.1" and so on.
7. delete the existing ruby source in ~/.rvm/src/ruby-1.9.1 etc
8. for each required ruby version
8.1 install the ruby with the exact version name, i.e. "rvm install ruby-1.9.1-p378" - rvm will see the local archive file in ~/.rvm/archives/ and install ruby from there.
8.2 update your rubygems version - this is the only bit of "rvm install" that failed for me, you can either fetch rubygems yourself, or run it from the cache:
  cd ~/.rvm/gems/ruby-1.9.1-p378\@global/gems/rubygems-update-1.3.7
  rvm 1.9.1
  ruby setup.rb

Ruby will now think it has all it's gems installed - but some may have broken binaries.  "gem list --local" will report what ruby *thinks* is installed - but it's not to be trusted.  So:
8.3 reinstall all the gems
  cd ~/.rvm/gems/ruby-1.9.1-p378/cache
  for file in *.gem; do gem install $file; done

Check the output for any errors due to missing libraries or the like.  But basically, this should work!

Note that for jruby, I think you don't need to do anything, as all the gems are java code (unless you are using something like Nokogiri which has some binary magic, in which case rebuilding the gem as above might work - haven't tried it yet)

I hope this is of use to someone!
Note that you could probably do steps 6 and 7 on your local machine before building the tarball.  I'm just writing it up as I did it...

- Korny

Korny Sietsma

unread,
Jul 27, 2010, 10:44:13 PM7/27/10
to rubyversi...@googlegroups.com
And again... this advice left too much gunk around really - it's better (and it turns out pretty simple) to build a new rvm install from scratch:
1. Fetch rvm from github as described at http://rvm.beginrescueend.com/rvm/install/:
2. tar up the rvm install and move it to your server
3. on the server, manually untar and install:
  mkdir -p ~/.rvm/src/ && cd ~/.rvm/src && rm -rf ./rvm/ && tar zxf [tarball] && cd rvm && ./install
4. copy all the ruby tarballs from your local ~/.rvm/archives to the server's ~/.rvm/archives
5. copy all the gems from your local ~/.rvm/gems/ruby-1.9.1-p378/cache to somewhere on the server
6. fetch the latest rubygems.tar.gz from http://rubygems.org/pages/download (or you can copy it from your working rvm install as described below)
7. on the server:
7.1 bootstrap rvm by reloading bash or whatever gets you the 'rvm' command working
7.2 "rvm install ruby-1.9.1-p378" will install ruby from the ~/.rvm/archives tarball - you need to be precise specifying version numbers
  - but 'gem update --system' will fail, so:
7.3 untar the rubygems.tar.gz somewhere, cd into it, and run 'ruby setup.rb'
7.4 go to wherever you put your gems in step 4, and run "gem install *.gem --local"

That ought to do it!  And leave you with a clean rvm setup.  Rinse and repeat steps 4 onwards for each ruby version.

- Korny

stevenhaddox

unread,
Sep 30, 2013, 2:03:06 PM9/30/13
to rubyversi...@googlegroups.com
Incredibly late on my reply here. RVM::FW is supposed to be similar to this, but with the idea of hosting files for RVM to install from in a centrally accessible (internal to your LAN) location. It's not meant to replace RVM, simply RVM's sources for it's source downloads. Hopefully the README updates (https://github.com/stevenhaddox/rvm_fw/blob/master/README.md) over the past few years as well as the sample RVM::FW instance (http://rvm-fw.herokuapp.com, no downloadable files as it's on the internet itself) help to better clarify how it works and what it's intent is.

-Steven
Reply all
Reply to author
Forward
0 new messages