如何在没有 sudo 的情况下安装 ruby gem?
How to install ruby gem without sudo?
配置新机器(Mac OS Mojave - 版本 10.14.2)。
安装 ruby 和 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
有谁知道这个错误是从哪里来的?
感谢您的帮助。
您在 gem 配置中只启用了非常旧的(未维护的)远程 gem 源。这可能是由一些旧的迁移配置或遵循一些非常陈旧和过时的建议引起的。
要解决此问题,您首先需要删除过时的 gem 来源,然后添加当前应该使用的唯一来源。为此,您可以 运行 从您的终端执行以下命令:
gem sources --remove http://gems.github.com/
gem sources --remove http://gems.rubyforge.org/
gem sources --add https://rubygems.org/
您必须删除您拥有的所有 gem 来源,并添加 https://rubygems.org/ instead. Note that http://gems.rubyforge.org/ and 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
希望对您有所帮助!
配置新机器(Mac OS Mojave - 版本 10.14.2)。
安装 ruby 和 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
有谁知道这个错误是从哪里来的? 感谢您的帮助。
您在 gem 配置中只启用了非常旧的(未维护的)远程 gem 源。这可能是由一些旧的迁移配置或遵循一些非常陈旧和过时的建议引起的。
要解决此问题,您首先需要删除过时的 gem 来源,然后添加当前应该使用的唯一来源。为此,您可以 运行 从您的终端执行以下命令:
gem sources --remove http://gems.github.com/
gem sources --remove http://gems.rubyforge.org/
gem sources --add https://rubygems.org/
您必须删除您拥有的所有 gem 来源,并添加 https://rubygems.org/ instead. Note that http://gems.rubyforge.org/ and 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
希望对您有所帮助!