简体   繁体   中英

Why is Rails not recognizing newly installed version of Ruby?

I have recently installed ruby 2.5.1 seemingly successfully, however when I type the command ruby -v into the "Command Prompt with ruby and rails" it returns the old value of 2.2.6. The strange thing is that when i type ruby -v into the normal Command prompt it returns the newly installed version 2.5.1.

I feel that I must change the configuration of the Rails environment somehow.

when I open the "command prompt with ruby and rails" it shows the following configuration

git:
  user.name:  USER_NAME_HERE
  user.email: EMAIL@********.com
  version:    git version 1.9.4.msysgit.2

ruby:
  bin:        C:/RailsInstaller/Ruby2.0.0/bin/ruby.exe
  version:    ruby 2.2.6p396 (2016-11-15 revision 56800) [i386-mingw32]

rails:
  bin:        C:/RailsInstaller/Ruby2.0.0/bin/rails.bat
  version:    Rails 5.1.6

How do I get Rails to recognize the newly installed version of ruby?

RailsInstaller is hard coded to the version of Ruby it installs. You can see this is the lines Ruby: bin and version. You probably installed Ruby 2.5 somewhere else. There are two approaches you can take

  • Before anything! Backup the RailsInstaller and Sites folders!!!! REALLY!
  • Adjust the RailsInstaller scripts to point to your new Ruby
  • Overwrite the older Ruby with the newer one and adjust the scripts where paths are different.

The key file is C:\\RailsInstaller\\Rubyx.xx\\setup_environment.bat

I suspect the key line (near line 11) is

SET RUBY_DIR=%CD%

I think that if this is changed to the path of the Ruby you want to use, operation will shift to that version. Might also need to change

SET ROOT_DIR=%CD%

To point to the RailsInstaller main folder.

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