3

配置新机器(Mac OS Mojave - 版本 10.14.2)。

使用rbenv. 我正在尝试安装一些 gem 并运行:

gem install rake bundler rspec rubocop pry pry-byebug hub colored octoki

但它给了我以下错误:

ERROR:  While executing gem ... (TypeError)
    incompatible marshal file format (can't be read)
    format version 4.8 required; 60.33 given

这是我的 Gem 环境:

RubyGems Environment:
  - RUBYGEMS VERSION: 2.7.6
  - RUBY VERSION: 2.5.3 (2018-10-18 patchlevel 105) [x86_64-darwin18]
  - INSTALLATION DIRECTORY: /Users/elise/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0
  - USER INSTALLATION DIRECTORY: /Users/elise/.gem/ruby/2.5.0
  - RUBY EXECUTABLE: /Users/elise/.rbenv/versions/2.5.3/bin/ruby
  - EXECUTABLE DIRECTORY: /Users/elise/.rbenv/versions/2.5.3/bin
  - SPEC CACHE DIRECTORY: /Users/elise/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /Users/elise/.rbenv/versions/2.5.3/etc
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-darwin-18
  - GEM PATHS:
     - /Users/elise/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0
     - /Users/elise/.gem/ruby/2.5.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
     - :sources => ["http://gems.rubyforge.org/", "http://gems.github.com"]
     - :benchmark => false
     - "gem" => "--no-document"
  - REMOTE SOURCES:
     - http://gems.rubyforge.org/
     - http://gems.github.com
  - SHELL PATH:
     - /Users/elise/.rbenv/versions/2.5.3/bin
     - /usr/local/Cellar/rbenv/1.1.1/libexec
     - ./bin
     - ./node_modules/.bin
     - /Users/elise/.rbenv/shims
     - /Users/elise/.rbenv/bin
     - /usr/local/bin
     - /usr/bin
     - /bin
     - /usr/sbin
     - /sbin
     - /usr/local/sbin

有谁知道这个错误来自哪里?谢谢您的帮助。

4

2 回答 2

2

您只在 gem 配置中启用了非常旧的(且未维护的)远程 gem 源。这可能是由一些旧的迁移配置或遵循一些非常古老和过时的建议引起的。

要解决此问题,您首先需要删除过时的 gem 源,然后添加当前应该使用的唯一一个。为此,您可以从终端运行以下命令:

gem sources --remove http://gems.github.com/
gem sources --remove http://gems.rubyforge.org/

gem sources --add https://rubygems.org/
于 2019-02-21T19:48:05.123 回答
1

您必须删除您拥有的所有 gem 资源并添加https://rubygems.org/。请注意, http: //gems.rubyforge.org/http://gems.github.com已永久失效,应将其删除。您可以通过运行列出您的来源:

gem sources 

你应该得到这样的东西:

*** CURRENT SOURCES ***

//gems.rubyforge.org/
//gems.github.com

1)删除所有来源:

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

2)添加正确的来源:

gem sources -a https://rubygems.org/

还有,从不 sudo gem install

希望这可以帮助!

于 2019-02-26T12:33:39.027 回答