简体   繁体   中英

rvm is not reading .ruby-version on production server

I have a rails 5.1 app, here is my .ruby-version

ruby-2.5.0

Here is the output of rvm list

rvm rubies

   ruby-2.3.1 [ x86_64 ]
=* ruby-2.4.0 [ x86_64 ]
   ruby-2.5.0 [ x86_64 ]

When I cd to "current" (deployed using Capistrano) I and I run the following:

RAILS_ENV=production bundle exec ruby --version

I get

ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-linux]

I thought .ruby-version was what triggers which ruby version is used. What am I doing wrong?

If you plan on using 2.5..0 as the default ruby version for your app run this on the server

rvm use --default 2.5.0

Its giving you 2.4.0 because its set up as the default and current ie =* means it is what will be used.

Also since you are deploying with capistrano and are using rvm you should consider using this gem.

https://github.com/capistrano/rvm

Per the docs you can set the ruby version explicitly, it also may likely be your server - for instance if you are using nginx you have to explicitly state your path in the nginx config file to your ruby version - but that all depends on your production configuration

https://rvm.io/rubies/default

$ rvm --default use 2.1.1

$ ruby -v

ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin12.0]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM