user1796624
user1796624

Reputation: 4007

rvm ruby version and rails server different ruby version

It seems rails server uses different ruby then the one that is set up by rvm.

How to make the rails server command use the same ruby as its set up in the rvm?

When I start the rails server, (write rails server in console) it outputs ruby 1.8.7 for ruby version. But when I write

 `ruby -v` 

to see the ruby version, I get ruby 1.9.3p0 for ruby version. Also I have installed rvm and when I type

rvm list 

it returns that I'm using ruby-1.9.3-p286, so rvm uses different ruby version than the rails server. I need to be able to start rails server with ruby-1.9.3. First I have installed ruby 1.8.7 that I installed rvm so I can use ruby-1.9.3. But it seems that I still can't use it with rails server. Thanks

Upvotes: 0

Views: 581

Answers (2)

Sticky
Sticky

Reputation: 3939

When you say "rails server", how are you running the server? Is it through Bundler? Or through a terminal command?

I believe each rvm Ruby version has its own Bundler (which uses the correct Ruby version specified from rvm). If you were to do rvm install ruby-2.x.x, you'll most likely run into ERROR: Gem bundler is not installed, run 'gem install bundler' first. Once you have run bundle exec rails console and are in the console, you can run RUBY_VERSION to see which version you're running.

If you're simply calling rails server, then your PATH might be messed up. You could run which -a rails to see the list of directories your computer searches through for the executables. If you see something like /usr/bin/rails, then this rails server version probably uses the system version of Ruby. I suspect that might be why the rvm Ruby version and Rails Ruby version are different.

Upvotes: 2

Yuriy Goldshtrakh
Yuriy Goldshtrakh

Reputation: 2014

the easiest way it to have .rvmrc file in the app directory where you specify which version of ruby you want to use

echo "rvm use 1.9.3" >> .rvmrc

Upvotes: 0

Related Questions