【问题标题】:An error occurred while installing "gem" and Bundler cannot continue. Mac OS - big sur安装“gem”时出错,Bundler 无法继续。 Mac OS - 大软件
【发布时间】:2021-01-06 21:55:23
【问题描述】:

我之前在升级到 Catalina 时使用 nio4r gem 发生了这个错误,@dmitry barskov 回答了它。在使用 json、oj 和 therubyracer 进行大 sur 升级后,现在发生了类似的问题(尝试使用 nio4r 的解决方案,但没有运气)。当我运行 gem list 时,我看到 gems 已安装但捆绑安装失败。所以我尝试了 bundle update json oj therubyracer。它适用于 json 和 oj,但对于 therubyracer,它会引发错误。

therubyracer 错误 -->

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /Users/me/.gem/gems/therubyracer-0.12.2/ext/v8
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r
./siteconf20210106-9670-edtaxk.rb extconf.rb --with-v8-dir\=/usr/local/opt/v8
checking for -lpthread... yes
checking for -lobjc... yes
checking for v8.h... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/$(RUBY_BASE_NAME)
    --with-pthreadlib
    --without-pthreadlib
    --with-objclib
    --without-objclib
    --enable-debug
    --disable-debug
    --with-v8-dir
    --with-v8-include
    --without-v8-include=${v8-dir}/include
    --with-v8-lib
    --without-v8-lib=${v8-dir}/lib
/Users/me/.gem/gems/libv8-3.16.14.19/ext/libv8/location.rb:50:in `configure': By using --with-system-v8, you have chosen to use the version
(Libv8::Location::System::NotFoundError)
of V8 found on your system and *not* the one that is bundled with
the libv8 rubygem.

However, your system version of v8 could not be located.

Please make sure your system version of v8 that is compatible
with 3.16.14.19 installed.

json 错误 -->

/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r
./siteconf20210106-29155-126itgi.rb extconf.rb
creating Makefile

current directory: /Users/me/.gem/gems/json-1.8.3/ext/json/ext/generator
make "DESTDIR=" clean

current directory: /Users/me/.gem/gems/json-1.8.3/ext/json/ext/generator
make "DESTDIR="
compiling generator.c
generator.c:861:25: error: use of undeclared identifier 'rb_cFixnum'
    } else if (klass == rb_cFixnum) {
                        ^
generator.c:863:25: error: use of undeclared identifier 'rb_cBignum'
    } else if (klass == rb_cBignum) {
                        ^
2 errors generated.
make: *** [generator.o] Error 1

make failed, exit code 2
*** LOCAL GEMS ***

bigdecimal (1.2.8)
bundler (1.17.3)
json (1.8.3)
libv8 (3.16.14.17)
oj (2.15.0)
rake (10.4.2)
ref (2.0.0)
therubyracer (0.12.3)

checking for v8.h... no我知道这可能是个问题,所以这是我尝试解决的问题,但未成功 ->

brew install v8-315
gem uninstall -a libv8
bundle config build.therubyracer --with-v8-dir=$(brew --prefix v8@3.15)
gem install libv8 -v '3.16.14.17' — —with-system-v8
gem uninstall -a therubyracer
bundle config build.libv8 --with-system-v8
gem install therubyracer -v '0.12.2' -- --with-v8-dir=$(brew --prefix v8@3.15)

当我进行捆绑更新时,它会卡在解决依赖关系中……我让它运行了 12 个小时才放弃。 当我删除我的 gemfile.lock 并运行 bundle install 时,它再次陷入解决依赖关系...。

我正在使用 ruby​​ v 2.3.1 捆绑器版本 1.17.3

我注意到的一件事是路径 /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby 显示 2.6.0,但我使用的是 2.3.1(通过运行 rbenv local 和 ruby​​ -v 确认)

如果需要任何其他信息,请告诉我。任何帮助将不胜感激。

【问题讨论】:

  • 首先要调查的肯定是你最后提到的问题 - 你的本地 shell 正在使用你的 rbenv 安装的 Ruby 版本,但从日志中很明显你的系统 Ruby 是正在使用。特别是此日志行:--ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/$(RUBY_BASE_NAME)。我将首先从 rbenv 卸载 Ruby,重新安装它,然后确保您的 bundle 可执行文件指向您安装 rbenv 的文件。

标签: ruby rubygems v8 macos-big-sur therubyracer


【解决方案1】:

我最终删除了项目文件夹并克隆了一个新文件夹。像@taylorthurlow 指出的那样,删除了所有 gem,重新安装了 rbenv。

一切正常,捆绑安装是绿色的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-03-14
    • 2022-01-20
    • 2017-02-09
    • 2018-09-08
    • 2020-01-16
    • 2021-06-25
    • 2014-01-12
    • 2018-04-05
    相关资源
    最近更新 更多