alex
alex

Reputation: 1900

RVM and Bundle in production

I'm in the process of upgrading my rails app originally in ruby 1.8.7 and rails 2.3.5 to ruby 1.9.2 and rails 2.3.12, and trying to use RVM and bundler, expecting the migration would be easier. Everything works great on my local machine, but I'm having a very hard time using RVM and deploy my bundle in production.

First of all, I'm not sure whether RVM loads my default environment correctly. I did a multi user install with my root user. Then I typed:

rvm --default use 1.9.2

and added:

[[ -s "/usr/local/rvm/scripts/rvm" ]] && ."/usr/local/rvm/scripts/rvm"

to my root user ~/.bash_profile, but when I open a new shell, and type "which ruby", it links to "/usr/local/rvm/bin/ruby". When I type "rvm default" then "which ruby", I get "/usr/local/rvm/rubies/ruby-1.9.2-p290/bin/ruby" as expected. So I'm not sure RVM is installed and configured properly.

Then, my bundle is installed in (I believe) in:

"/home/web-app/www/shared/bundle"

and when I type "bundle list" I can see the gems I installed (including my rails 2.3.12). But when I do "gem list" I only see:

*** LOCAL GEMS ***

bundler (1.0.18) 
daemon_controller (0.2.6) 
fastthread (1.0.7)
passenger (3.0.8) 
rack (1.3.2) 
rake (0.9.2 ruby)

The gems from my bundle are not part of the list. So right now, on my live site (sigh), passenger can't find Rails 2.3.12 (accessible from the bundle, not in Local Gems). Not sure how to tell passenger there are some gems available in the shared/bundle folder...

Would love some help!

-- EDITS:

1: I hadn't install passenger the right way. I used

sudo passenger-install-apache2-module

Using "sudo" caused the install to happen on my system ruby, not on the RVM one. Once I ran the command WITHOUT sudo, the console gave me the right lines to insert into my apache2.conf file, and I was able to start my server. Good first step, but now I can't start thinking-sphinx: it complains it can't find Rails 2.3.12...

  1. By default, Rails 2.3 only loads gems from the Gemset. I had to add a little code to tell my application to load the bundled Gems as well, as explained here.

Upvotes: 1

Views: 1078

Answers (1)

alex
alex

Reputation: 1900

When using RVM, install Passenger without the sudo command. Just do:

passenger-install-apache2-module

It will give you the config lines matching your RVM environment (as opposed to your system Ruby's env).

Upvotes: 2

Related Questions