0

I have multiple version of rails installed. But when I start the server with "rails s" it always uses the latest one. Is there a way to specify the version of rails (and all dependent gems) that should be used? (And how would I specify that in Pasenger?) Yes, I could use RVM or similar - but this I would like to avoid.

Thanks in advance!

Daniel
  • 2,409
  • 2
  • 26
  • 42
  • I think this still works? see http://stackoverflow.com/questions/6148308/set-rails-version-as-default - `rails _3.2.15_ server` - I believe passenger would use the version specified in the Gemfile and so this would not be needed in that case? – house9 Nov 09 '13 at 18:48

2 Answers2

0

You can't do that with rails server command. Every project depend from a GemFile. But you can create a bash script that will move a custom specify GemFile to the default GemFile then start the server.

vi /script/rails4_to_rails3
#/bin/bash
mv /opt/web/my_app/GemFile /opt/web/my_app/GemFile.rails4
cp /script/GemFile.rails3 /opt/web/my_app/GemFile
bundle install
rails s

I'm not a Passenger Expert but in my opinion it's impossible to.

Ludovic
  • 1,992
  • 1
  • 21
  • 44
0

Phusion Passenger author here.

The version of Rails that is loaded does not depend on 'rails server', and also does not depend on Passenger. RVM also has got nothing to do with it.

It only depends on your Gemfile.lock, which locks down all gem versions in your project. If you want a different version of Rails, you need to modify your Gemfile to specify that exact version, and run bundle install to update Gemfile.lock.

Hongli
  • 18,682
  • 15
  • 79
  • 107
  • Meaning: In case all my applications use the same Ruby version, then there is no need for RVM or silimar solutions? What is then the purpose of having the possibility to create different gemset in RVM? – Daniel Nov 12 '13 at 11:14
  • Correct. The RVM gemset mechanism exists because it predates Bundler. Nowadays you should use Bundler instead of gemsets. See my comment here: http://www.reddit.com/r/ruby/comments/1nvujm/time_to_hand_over_the_reigns_before_capistrano/ccmq7ob?context=3 – Hongli Nov 12 '13 at 14:21
  • @Hongli It's exactly my answer ;) – Ludovic Nov 23 '13 at 10:20