2

I have a box with 3 Rails apps on it. I wan't to upgrade one of the apps so that it uses Ruby 2.0.0, while leaving the others running on 1.9.3-p394. I have both those Rubies installed via Rvm.

I'm trying to control the Ruby version that each app uses via it's Gemfile.

# Gemfile
ruby '2.0.0'

So, I changed the version number in the Gemfile locally, made sure it all worked, committed and now I'm trying to deploy the change to the server.

However, the cap deploy fails at this point

bundle install --gemfile [path to release Gemfile] --path [path to app bundle] --deployment --quiet --without development test

because

Your Ruby version is 1.9.3, but your Gemfile specified 2.0.0

This is correct technically, my Gemfile does specify 2.0.0 and the app is currently running on 1.9.3. I'm trying to make it change versions before bundling though. How do I do that?

Andrew Marshall
  • 95,083
  • 20
  • 220
  • 214
David Tuite
  • 22,258
  • 25
  • 106
  • 176

3 Answers3

1

Your PATH is not set up correctly. You probably don't have bin: as the first entry in your path. That would lead to this error.

Even if you're not using Heroku it's worth reading this page on troubleshooting that issue: https://devcenter.heroku.com/articles/ruby-versions

Here is a link to an answer which will explain how to change your PATH on the server: Capistrano: Can I set an environment variable for the whole cap session?

Community
  • 1
  • 1
Richard Jordan
  • 8,066
  • 3
  • 39
  • 45
  • Which `bin` do I want in the path? The one in the Rails root right? I've added `set :default_environment, { 'PATH' => "[path to rails root]/bin:$PATH" }` to my deploy config and it doesn't seem to change anything. – David Tuite Mar 26 '13 at 02:41
  • first element in PATH should be just "bin:" according to the articles I found googling for an answer to this - see the heroku article – Richard Jordan Mar 26 '13 at 02:43
  • as a separate strategy have you looked at https://rvm.io/integration/capistrano/ already? – Richard Jordan Mar 26 '13 at 02:45
  • Yeah, tried naked `bin` too. Doesn't work. There's definitely a few steps on the `rvm-capistrano` Gihub readme that I haven't done. Will try them now. – David Tuite Mar 26 '13 at 02:52
  • Yeah - I am still learning managing this stuff all together myself so I'm trying to track this one down for the old memorybanks in case I run into it later so I'll add anything I find to this comment thread or update the answer if I find a definitive one. – Richard Jordan Mar 26 '13 at 02:54
  • Ok, kinda silly but I had `set :rvm_ruby_string, :default` in my deploy config which obviously was forcing Rvm to use `1.9.3` when deploying. The issue still isn't really solved though since I can't see a good way to tell it to use whatever is in the Gemfile. – David Tuite Mar 26 '13 at 03:56
  • Well I hate to suggest it - and you're probably doing it anyway - but now go through the previous steps again and it may now work :-) – Richard Jordan Mar 26 '13 at 04:34
0

If you have rvm maybe you can try to do

rvm use 2.0.0

before your bundler call.

MervS
  • 5,724
  • 3
  • 23
  • 37
0

If you're using rvm set the default to ruby 2.0.0 on your server

rvm --default use 2.0.0

Resolved the problem for me deploying to an AWS server from my mac - but I guess if I need to update my older sites I'll have to set the default back to 1.9.3 before deploying.

Peter Todd
  • 8,561
  • 3
  • 32
  • 38