4.2.6我有一个用 ruby 编写的Rails( ) 项目2.2.0。
我正在尝试升级到 ruby2.5 。为此,我在 Rails 存储库中将文件更改.ruby-version为ruby-2.5.0.
在终端中,ruby 版本是正确的:
ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin17]
Run Code Online (Sandbox Code Playgroud)
当我跑步时
bundle update --bundler
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
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
Run Code Online (Sandbox Code Playgroud)
我尝试手动更新 json gem:
gem install json -v '1.8.3'
Run Code Online (Sandbox Code Playgroud)
没有成功:
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
Run Code Online (Sandbox Code Playgroud)
此时,我不知道该google什么,如何调试。
如果我跑
bundle install
Run Code Online (Sandbox Code Playgroud)
我收到以下错误
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`
Run Code Online (Sandbox Code Playgroud)
不确定这意味着什么,我的内容Gemfile.lock是:
bundler (>= 1.3.0, < 2.0)
Run Code Online (Sandbox Code Playgroud)
而且,在我的 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?
Run Code Online (Sandbox Code Playgroud)
这是因为你的宝石资源不对。
尝试这些来纠正它
gem sources -r http://gems.rubyforge.org/
gem sources -r http://gems.github.com
gem sources -a https://rubygems.org/
Run Code Online (Sandbox Code Playgroud)
然后像你一样再次捆绑