简体   繁体   English

升级到Rails 5.1.4的问题

[英]Issue upgrading to Rails 5.1.4

I attempt to upgrade to Rails 5.1.4. 我尝试升级到Rails 5.1.4。 Seems to update without an issue, however, a version check still shows 5.0.4. 似乎可以毫无问题地进行更新,但是,版本检查仍显示5.0.4。 Any ideas? 有任何想法吗?

Ruby Version: Ruby版本:

ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16] 红宝石2.4.1p111(2017-03-22修订版58053)[x86_64-darwin16]

Terminal Output: 终端输出:

$ rails -v
Rails 5.0.4
$ gem install rails --version=5.1.4
Successfully installed rails-5.1.4
Parsing documentation for rails-5.1.4
Done installing documentation for rails after 0 seconds
1 gem installed
$ rails -v
Rails 5.0.4

Uninstall all versions of rails installed in your system by: gem uninstall rails 通过以下方法来gem uninstall rails系统中安装的所有版本的railsgem uninstall rails

It should prompt you with something like below 它会提示您以下内容

Select gem to uninstall: 选择要卸载的宝石:
1. rails-4.2.6 1.导轨4.2.6
2. rails-5.1.4 2.滑轨5.1.4
3. All versions 3.所有版本
Choose Option "All Versions" and uninstall all 选择选项“所有版本”并卸载所有

Install the desired rails version: 安装所需的rails版本:

gem install rails --version=5.1.4
rails -v
5.1.4

Update : Since you mentioned using bundle install , check if rails is specified with 5.1.4 in your Gemfile or not. 更新 :由于您提到使用bundle install ,请检查是否在Gemfile中用5.1.4指定了rails

Sometimes, i met this problem, because you have two versions of rails in your railties . 有时候,我遇到了这个问题,因为你有你的轨道的两个版本railties You can do this 你可以这样做

gem uninstall railties

Select gem to uninstall:
1. railties-5.1.4
2. railties-5.0.4
3. All versions

Type 3 to remove all, then you can reinstall rails 5.1.4 again. 键入3以删除所有,然后可以重新安装rails 5.1.4

Either use 无论使用

bin/rails -v

or 要么

bundle exec rails -v

to select the version of rails specified in your Gemfile 选择您的Gemfile中指定的rails版本

Or do what I do and install https://direnv.net/ and add a .envrc file to the project. 或者执行我的操作并安装https://direnv.net/并将.envrc文件添加到项目中。 Then when you cd to that project, the path will be updated appropriately and rails -v will work as expected: 然后,当您cd到该项目时,路径将被适当更新,并且rails -v将按预期工作:

PATH_add "./bin"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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