从 ruby 2.2.0 更新到 2.5

Update from ruby 2.2.0 to 2.5

我有一个 Rails (4.2.6) 项目是用 ruby 2.2.0.

编写的

我正在尝试升级到 ruby 2.5。为此,我在 Rails 存储库中将文件 .ruby-version 更改为 ruby-2.5.0

在终端中,ruby版本是正确的:

ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin17]

当我运行

bundle update --bundler 

我收到以下错误:

6 warnings and 2 errors generated.
make: *** [generator.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/albert/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/json-1.8.3 for inspection.
Results logged to /Users/albert/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/extensions/x86_64-darwin-17/2.5.0-static/json-1.8.3/gem_make.out

An error occurred while installing json (1.8.3), and Bundler cannot continue.
Make sure that `gem install json -v '1.8.3'` succeeds before bundling.

In Gemfile:
  rails was resolved to 4.2.6, which depends on
    actionmailer was resolved to 4.2.6, which depends on
      actionpack was resolved to 4.2.6, which depends on
        actionview was resolved to 4.2.6, which depends on
          rails-dom-testing was resolved to 1.0.7, which depends on
            rails-deprecated_sanitizer was resolved to 1.0.3, which depends on
              activesupport was resolved to 4.2.6, which depends on
                json

我尝试手动更新 json gem:

gem install json -v '1.8.3' 

没有成功:

Getting SRV record failed: DNS result has no information for _rubygems._tcp.gems.rubyforge.org
HEAD http://gems.rubyforge.org/api/v1/dependencies
301 Moved Permanently
HEAD https://rubygems.org
200 OK
Getting SRV record failed: DNS result has no information for _rubygems._tcp.gems.github.com
HEAD http://gems.github.com/api/v1/dependencies
301 Moved Permanently
HEAD http://gems.github.io/api/v1/dependencies
404 Not Found
GET http://gems.github.com/prerelease_specs.4.8.gz
301 Moved Permanently
GET http://gems.github.io/prerelease_specs.4.8.gz
404 Not Found
GET http://gems.github.com/specs.4.8.gz
301 Moved Permanently
GET http://gems.github.io/specs.4.8.gz
404 Not Found
HEAD https://api.rubygems.org/api/v1/dependencies
200 OK
GET https://rubygems.org?gems=json
200 OK
ERROR:  While executing gem ... (TypeError)
    incompatible marshal file format (can't be read)
    format version 4.8 required; 60.33 given

此时,我不知道google,如何调试。

如果我运行

bundle install

我收到以下错误

    2: from ./bin/bundle:3:in `<main>'
    1: from /Users/albert/.rbenv/versions/2.5.0/lib/ruby/2.5.0/rubygems.rb:263:in `bin_path'
/Users/albert/.rbenv/versions/2.5.0/lib/ruby/2.5.0/rubygems.rb:289:in `find_spec_for_exe': Could not find 'bundler' (1.14.3) required by your /Users/albert/localDocuments/CodingArea/Clients/hanspeter/book/Gemfile.lock. (Gem::GemNotFoundException)
To update to the lastest version installed on your system, run `bundle update --bundler`.
To install the missing version, run `gem install bundler:1.14.3`

不确定这是什么意思,我在 Gemfile.lock 中的内容是:

bundler (>= 1.3.0, < 2.0)

而且,我是我的 Gemfile,我有一个来源:

source 'https://rubygems.org'
```

As far as I understood, bundle is a gem manager that works on Mac, and bundler is a gem that manages gems?

是因为你的gem资源有误

试试这些来纠正它

gem sources -r  http://gems.rubyforge.org/
gem sources -r http://gems.github.com
gem sources -a https://rubygems.org/

然后像您一样再次捆绑