简体   繁体   中英

Your Ruby version is 2.3.1 but your Gemfile specified 2.5.1

Whenever I run a Rails command, it states that my Ruby version is 2.3.1 but my Gemfile specified 2.5.1. However, "ruby -v" returns "ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]", my path has no references to ruby 2.3.1, and running "rvm list" shows a properly green highlighted 2.5.1. Bundler is installed, and when I try to run bundle install inside a created Rails folder, a get another "Your Ruby version is 2.3.1 but your Gemfile specified 2.5.1" message. Please advise.

$PATH:

-bash: /home/alowverus/.rvm/gems/ruby-2.5.1/bin:/home/alowverus/.rvm/gems/ruby-2.5.1@global/bin:/usr/share/rvm/rubies/ruby-2.5.1/bin:/usr/share/rvm/bin:/home/alowverus/.rvm/gems/ruby-2.5.1/bin:/home/alowverus/.rvm/gems/ruby-2.5.1@global/bin:/home/alowverus/.rvm/gems/ruby-2.5.1/bin:/home/alowverus/.rvm/gems/ruby-2.5.1@global/bin:/home/alowverus/.rvm/gems/ruby-2.5.1/bin:/home/alowverus/.rvm/gems/ruby-2.5.1@global/bin:/home/alowverus/.rvm/gems/ruby-2.5.1/bin:/home/alowverus/.rvm/gems/ruby-2.5.1@global/bin:/home/alowverus/bin:/home/alowverus/.local/bin:/home/alowverus/.rvm/gems/ruby-2.5.1/bin:/home/alowverus/.rvm/gems/ruby-2.5.1@global/bin:/home/alowverus/bin:/home/alowverus/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin: No such file or directory

Further information in response to answers: "which rails" returns "/home/alowverus/.rvm/gems/ruby-2.5.1/bin/rails", as expected

Create two files in the root one .ruby-version mention ruby-2.3.1 and .ruby-gemset mention @gemset-name and cd back to the same directory which will create the rvm wrapper for that application then run

rvm current

which outputs like something

ruby-2.3.1@gemset-name

then run

gem install bundler
bundle

may be helpful for you

I would try (in no particular order):

  • which rails , is it the correct one?
  • bundle exec rails c (or whatever your command is)
  • rvm reload
  • To start clean, rvm implode and try reinstalling rvm and your Ruby version.

Your Ruby version is 2.3.8, but your Gemfile specified 2.3.1

check ruby version with ruby -v [version like 2.3.8] make sure ruby version should be same on ruby versions as well as in your GemFile if you have not the same version then your put command on your bash_profile (terminal) rbenv global 2.3.8 & rbenv shell 2.3.8 (the version you can specified accordingly ) then delete your Gemfile.lock then install bundle and install bundler . these steps working form me.

rbenv global 2.3.8
rbenv shell 2.3.8
delete your Gemfile.lock
install bundle 
install bundler

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