0
votes

I need to deploy a Rails 3/Phusion Passenger/Apache2 app to an Ubuntu 12.04 server without installing ANY gems on the server.

I can install any Debian packages.

How can I include all needed gems (including Rails, a couple of gems installed from git projects on github, and a bunch of regular gems installed from rubygems.org) inside my project so that, after deployment, Passenger will find Rails and all the gems and be happy?

(I know many people will probably be curious WHY I would want to do this. I can't talk about that, unfortunately. Sorry.)

Here are some things that have not worked. One of them might work if revised a little, I don't know:

Failed method 1:

  1. On Ubuntu 12.04 dev machine. Ruby 1.9.3. Bundler 1.3.5. bundle package --all. Git commit.
  2. On Ubuntu 12.04 server machine (gem installation from Internet not possible). Deploy project files and install packages (apache2, ruby1.9.3, ruby-bundler, rubygems, libapache2-mod-passenger which brings ruby1.8 with it). bundle -v gives Bundler version 1.0.15 (from ruby-bundler package). Make sure .bundle/config file from dev machine is also deployed. bundle install --local tries to download git gems from github, so fail.
3
Trying using gem unpack as shown in this article. Hopefully that works better than the two things you have tried so far.jvperrin

3 Answers

1
votes

Try using bundle package --all, which should save your gems into ./vendor/cache. You could also unpack the gems on your local environment with gem unpack --target vendor to save them in the vendor directory. Then you can give a location in the Gemfile so that your application can find the gems. Can you just not use the network to install gems, or are you really not allowed to install gems in any way?

Sources: 1, 2

0
votes

Try using the pkgr tool, which can convert your Rails app and all dependencies into a single installable Debian package.

0
votes

update-alternatives --install /usr/bin/ruby ruby /usr/bin/ruby1.9.3 200 update-alternatives --install /usr/bin/gem gem /usr/bin/gem1.9.3 200

(Phusion Passenger doesn't care about this, but it's probably a good idea for the gems we are about to install and for debugging stuff with the Rails console or whatever in the future.)

  • gem install --local vendor/bundler-1.3.5.gem

  • bundle install --local

  • Set up all your other Apache config...

  • service apache2 restart