Gem::Ext::BuildError: ERROR: Failed to build gem native extension on macOS Monterey
Gem::Ext::BuildError: ERROR: Failed to build gem native extension on macOS Monterey
当我 运行 bundle install
在我的 rails 5 项目上时,我在 gem 上收到一些错误,这些错误似乎具有本机扩展。这是其中一个 gems 的输出顶部:
Installing nio4r 1.2.1 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
checking for unistd.h... yes
checking for rb_thread_blocking_region()... no
checking for rb_thread_call_without_gvl()... yes
checking for sys/select.h... yes
checking for poll.h... yes
checking for sys/epoll.h... no
checking for sys/event.h... yes
checking for sys/queue.h... yes
checking for port.h... no
checking for sys/resource.h... yes
creating Makefile
current directory: /Users/<my-username>/.rvm/gems/ruby-2.7.4/gems/nio4r-1.2.1/ext/nio4r
make "DESTDIR=" clean
current directory: /Users/<my-username>/.rvm/gems/ruby-2.7.4/gems/nio4r-1.2.1/ext/nio4r
make "DESTDIR="
compiling monitor.c
monitor.c:91:24: warning: '(' and '{' tokens introducing statement expression appear in different macro expansion contexts [-Wcompound-token-split-by-macro]
if(interests_id == rb_intern("r")) {
^~~~~~~~~~~~~~
/Users/<my-username>/.rvm/rubies/ruby-2.7.4/include/ruby-2.7.0/ruby/ruby.h:1847:23: note: expanded from macro 'rb_intern'
__extension__ (RUBY_CONST_ID_CACHE((ID), (str))) : \
^
monitor.c:91:24: note: '{' token is here
if(interests_id == rb_intern("r")) {
^~~~~~~~~~~~~~
我已经尝试了很多东西。
根据 我尝试了以下建议:
# didn't fix it
bundle config build.nio4r --with-cflags="-std=c99"
bundle
# didn't fix it
xcode-select --install
sudo xcodebuild -license accept
bundle
我还参考了 this Go Rails guide,特别是处理需要 C 扩展的 gem 的“最终步骤”部分,但该命令似乎不适用,因为我没有从 Mojave 迁移我的 macOS。
此时我不确定接下来要尝试什么。最终:问题似乎围绕着无法安装需要 C 扩展的 gem。
环境:
- macOS 蒙特雷版本
12.2
- 使用 ruby 版本
2.7.4
的 rvm
- 项目正在使用 rails 版本
5.0.1
事实证明,问题是在 Gemfile.lock 文件中,它被锁定为使用旧版本的 bundler
。我们简单的删除了Gemfile.lock,和re-ranbundle
重新生成Gemfile.lock。那解决了它。它现在在 Gemfile.lock 文件的底部这样说,所以它喜欢这个版本的捆绑器:
BUNDLED WITH
2.3.9
当我 运行 bundle install
在我的 rails 5 项目上时,我在 gem 上收到一些错误,这些错误似乎具有本机扩展。这是其中一个 gems 的输出顶部:
Installing nio4r 1.2.1 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
checking for unistd.h... yes
checking for rb_thread_blocking_region()... no
checking for rb_thread_call_without_gvl()... yes
checking for sys/select.h... yes
checking for poll.h... yes
checking for sys/epoll.h... no
checking for sys/event.h... yes
checking for sys/queue.h... yes
checking for port.h... no
checking for sys/resource.h... yes
creating Makefile
current directory: /Users/<my-username>/.rvm/gems/ruby-2.7.4/gems/nio4r-1.2.1/ext/nio4r
make "DESTDIR=" clean
current directory: /Users/<my-username>/.rvm/gems/ruby-2.7.4/gems/nio4r-1.2.1/ext/nio4r
make "DESTDIR="
compiling monitor.c
monitor.c:91:24: warning: '(' and '{' tokens introducing statement expression appear in different macro expansion contexts [-Wcompound-token-split-by-macro]
if(interests_id == rb_intern("r")) {
^~~~~~~~~~~~~~
/Users/<my-username>/.rvm/rubies/ruby-2.7.4/include/ruby-2.7.0/ruby/ruby.h:1847:23: note: expanded from macro 'rb_intern'
__extension__ (RUBY_CONST_ID_CACHE((ID), (str))) : \
^
monitor.c:91:24: note: '{' token is here
if(interests_id == rb_intern("r")) {
^~~~~~~~~~~~~~
我已经尝试了很多东西。
根据
# didn't fix it
bundle config build.nio4r --with-cflags="-std=c99"
bundle
# didn't fix it
xcode-select --install
sudo xcodebuild -license accept
bundle
我还参考了 this Go Rails guide,特别是处理需要 C 扩展的 gem 的“最终步骤”部分,但该命令似乎不适用,因为我没有从 Mojave 迁移我的 macOS。
此时我不确定接下来要尝试什么。最终:问题似乎围绕着无法安装需要 C 扩展的 gem。
环境:
- macOS 蒙特雷版本
12.2
- 使用 ruby 版本
2.7.4
的 rvm
- 项目正在使用 rails 版本
5.0.1
事实证明,问题是在 Gemfile.lock 文件中,它被锁定为使用旧版本的 bundler
。我们简单的删除了Gemfile.lock,和re-ranbundle
重新生成Gemfile.lock。那解决了它。它现在在 Gemfile.lock 文件的底部这样说,所以它喜欢这个版本的捆绑器:
BUNDLED WITH
2.3.9