首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >不能在M1处理器上使用Nokogiri

不能在M1处理器上使用Nokogiri
EN

Stack Overflow用户
提问于 2022-09-13 04:06:01
回答 1查看 330关注 0票数 0

我在使用M1处理器和Nokogiri时遇到了问题。

Gemfile

代码语言:javascript
运行
复制
...
gem 'nokogiri', '>= 1.13.5'
...

当我运行bundle install时,一切似乎都很好,但是当我尝试运行规范时,我看到了错误:

代码语言:javascript
运行
复制
LoadError:
  dlopen(/Users/ruslan/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/nokogiri-1.13.6/lib/nokogiri/nokogiri.bundle, 0x0009): tried: '/Users/ruslan/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/nokogiri-1.13.6/lib/nokogiri/nokogiri.bundle' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')) - /Users/ruslan/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/nokogiri-1.13.6/lib/nokogiri/nokogiri.bundle

我尝试过用gem install nokogiri -v 1.13.6 --platform arm64-darwin安装Nokogiri,现在看起来是这样的:

野锦葵( nokogiri -versions )

代码语言:javascript
运行
复制
# Nokogiri (1.13.6)
    ---
    warnings: []
    nokogiri:
      version: 1.13.6
      cppflags:
      - "-I/Users/ruslan/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/nokogiri-1.13.6-arm64-darwin/ext/nokogiri"
      - "-I/Users/ruslan/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/nokogiri-1.13.6-arm64-darwin/ext/nokogiri/include"
      - "-I/Users/ruslan/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/nokogiri-1.13.6-arm64-darwin/ext/nokogiri/include/libxml2"
      ldflags: []
    ruby:
      version: 2.7.2
      platform: arm64-darwin21
      gem_platform: arm64-darwin-21
      description: ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [arm64-darwin21]
      engine: ruby
    libxml:
      source: packaged
      precompiled: true
      patches:
      - 0001-Remove-script-macro-support.patch
      - 0002-Update-entities-to-remove-handling-of-ssi.patch
      - 0003-libxml2.la-is-in-top_builddir.patch
      - 0004-use-glibc-strlen.patch
      - 0005-avoid-isnan-isinf.patch
      - 0006-update-automake-files-for-arm64.patch
      - '0008-htmlParseComment-handle-abruptly-closed-comments.patch'
      - '0009-allow-wildcard-namespaces.patch'
      libxml2_path: "/Users/ruslan/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/nokogiri-1.13.6-arm64-darwin/ext/nokogiri"
      memory_management: ruby
      iconv_enabled: true
      compiled: 2.9.14
      loaded: 2.9.14
    libxslt:
      source: packaged
      precompiled: true
      patches:
      - 0001-update-automake-files-for-arm64.patch
      datetime_enabled: true
      compiled: 1.1.35
      loaded: 1.1.35
    other_libraries:
      zlib: 1.2.12
      libiconv: '1.16'
      libgumbo: 1.0.0-nokogiri

但是,当我试图只运行这个版本的规范时,我有一个错误:

代码语言:javascript
运行
复制
Could not find nokogiri-1.13.6 in any of the sources
Run `bundle install` to install missing gems.

因此,为了避免这个错误,我必须通过bundle install安装Nokogiri,但是它安装错误的版本,而不是针对arm平台,然后我遇到了这个平台的问题。如果我通过gem install命令安装Nokogiri,bundler就不会看到它。

我的包配置

代码语言:javascript
运行
复制
Settings are listed in order of priority. The top value will be used.
build.libv8
Set for the current user (/Users/ruslan/.bundle/config): "--with-system-v8"

build.libxml-ruby
Set for the current user (/Users/ruslan/.bundle/config): "--with-xml2-config=/usr/local/opt/libxml2/bin/xml2-config"

build.nokogiri
Set for your local app (/Users/ruslan/3commas/3commas/.bundle/config): "--use-system-libraries"

default
Set for the current user (/Users/ruslan/.bundle/config): "2.2.21"

force_ruby_platform
Set for your local app (/Users/ruslan/3commas/3commas/.bundle/config): true
Set for the current user (/Users/ruslan/.bundle/config): true

github.https
Set for the current user (/Users/ruslan/.bundle/config): "true"

也许有人知道怎么解决这个问题?事先非常感谢!

EN

回答 1

Stack Overflow用户

发布于 2022-09-13 04:14:11

我想知道这是否是一个与Gemfile.lock文件相关的问题,该文件可以绑定显式平台。您可以通过在该文件中查找PLATFORMS来进行检查。

如果你通过邦德勒将苹果的ARM平台添加到你的安装程序中,这可能有助于正确版本的nokogiri捆绑吗?尝试在命令行上运行以下命令:

代码语言:javascript
运行
复制
bundle lock --add-platform arm64-darwin-21
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73697448

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档