Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/59.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 错误:执行gem时。。。(TypeError)封送处理文件格式不兼容(无法读取)_Ruby On Rails_Ruby_Rubygems_Nokogiri_Macos Mojave - Fatal编程技术网

Ruby on rails 错误:执行gem时。。。(TypeError)封送处理文件格式不兼容(无法读取)

Ruby on rails 错误:执行gem时。。。(TypeError)封送处理文件格式不兼容(无法读取),ruby-on-rails,ruby,rubygems,nokogiri,macos-mojave,Ruby On Rails,Ruby,Rubygems,Nokogiri,Macos Mojave,我在使用Ruby 2.4.4版和macOS Mojave运行捆绑安装时遇到了这个问题: 获取nokogiri 1.8.5 使用本机扩展安装nokogiri 1.8.5 Gem::Ext::BuildError:错误:无法生成Gem本机扩展。 错误:无法发现libxml2在系统上的位置。请 确保安装了'pkg config'。 所以我跑了 xcode选择--安装 但是当我运行gem install nokogiri时,我得到了以下输出: 错误:执行gem时。。。(打字错误) 不兼容的封送处理文

我在使用Ruby 2.4.4版和macOS Mojave运行捆绑安装时遇到了这个问题:

获取nokogiri 1.8.5
使用本机扩展安装nokogiri 1.8.5
Gem::Ext::BuildError:错误:无法生成Gem本机扩展。
错误:无法发现libxml2在系统上的位置。请
确保安装了'pkg config'。
所以我跑了

xcode选择--安装
但是当我运行
gem install nokogiri
时,我得到了以下输出:

错误:执行gem时。。。(打字错误)
不兼容的封送处理文件格式(无法读取)
格式版本4.8要求;60.33给定
我试图将我的
cookies\u序列化程序设置为
:hybrid

Rails.application.config.action\u dispatch.cookies\u序列化程序=:hybrid
但什么都没用


有办法解决这个问题吗?我现在甚至无法运行Rails服务器。

请尝试删除您的
~/.gemrc
。我在莫哈韦也遇到了同样的问题,这就解决了我的问题。

多亏了摩根·贾里的回答,这就是我的工作:

我检查了我当前的来源,事实上它们已经过时了:

gem sources
它是印刷的

*** CURRENT SOURCES ***
http://gems.rubyforge.org/
http://gems.github.com
所以我运行这个脚本来删除它们,并用


你必须删除所有你拥有的gem资源,然后添加。请注意,和是永久性的,应该移除。您可以通过运行以下命令列出源:

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/

希望这有帮助

我想给这个答案添加一些细微差别:
~/.gemrc
包含一个引用,使用rubyforge作为源。这在10年前是相关的,但是现在gems在rubygems.org上直播,所以你应该有一个参考来拥有
https://rubygems.org
改为源代码。非常感谢Morgan!我检查了我的电流源,它们已经过时了,所以我删除了它们,并将它们替换为。然后我可以安装nokogori并运行bundle安装,没有任何问题。删除你的.gemrc不是****解决方案。事实上,一个.gemrc可以有很多有用的控件,比如设置
gem:--no ri--no rdoc
::这个问题的正确答案是下面有更多投票的那一个。这很有帮助,我有了设置,消除了我的问题
gem sources -a https://rubygems.org/