当我使用Ruby版本2.4.4和macOS Mojave运行bundle install
时遇到了这个问题:
Fetching nokogiri 1.8.5
Installing nokogiri 1.8.5 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
ERROR: cannot discover where libxml2 is located on your system. please
make sure `pkg-config` is installed.
所以我跑了
xcode-select --install
但是当我运行gem install nokogiri
时,我得到了以下输出:
ERROR: While executing gem ... (TypeError)
incompatible marshal file format (can't be read)
format version 4.8 required; 60.33 given
我试着将我的cookies_serializer
设置为:hybrid
:
Rails.application.config.action_dispatch.cookies_serializer = :hybrid
但没有任何效果。
有没有办法来解决这个问题?我现在甚至无法运行我的Rails服务器。
感谢Morgan Jarry的回答,这对我有用:
我检查了我目前的消息来源,确实它们已经过时了:
gem sources
它印了
*** CURRENT SOURCES ***
http://gems.rubyforge.org/
http://gems.github.com
所以我运行这个脚本来删除它们并用https://rubygems.org/替换它们
gem sources -r http://gems.rubyforge.org/
gem sources -r http://gems.github.com
gem sources -a https://rubygems.org/
尝试删除你的~/.gemrc
。我在Mojave上遇到了同样的问题,这解决了我的问题。
您必须删除所有宝石来源并添加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/
希望这可以帮助!