从ruby 2.2.0更新到2.5

时间:2019-07-02 16:47:12

标签: ruby rubygems

我有一个用ruby 4.2.6编写的Rails(2.2.0)项目。

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

在终端中,红宝石版本正确:

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

在这一点上,我不知道该用什么,如何调试。

如果我运行

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?

1 个答案:

答案 0 :(得分:3)

这是因为您的宝石资源不正确。

尝试使用这些内容进行纠正

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

然后像您一样再次捆绑