本文介绍了错误:执行gem ...(TypeError)不兼容的封送文件格式时(无法读取)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在Ruby版本2.4.4和macOS Mojave中运行bundle install时遇到了这个问题:

I encountered this issue when I run bundle install with Ruby version 2.4.4 and macOS Mojave:

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时,我得到了以下输出:

But then when I run gem install nokogiri I got the following output:

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服务器.

Is there a way to fix this? I cannot even run my Rails server right now.

推荐答案

感谢Morgan Jarry的回答,这对我有用:

Thanks to Morgan Jarry answer, this is what worked for me :

我检查了我当前的消息来源,但实际上它们已经过时了:

I checked my current sources and indeed they were outdated :

gem sources

已打印

*** CURRENT SOURCES ***
http://gems.rubyforge.org/
http://gems.github.com

因此,我运行了该脚本以将其删除,并用 https://rubygems.org/

So I ran this script to remove them and replaced them with https://rubygems.org/

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

这篇关于错误:执行gem ...(TypeError)不兼容的封送文件格式时(无法读取)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 15:09