賞金將在 2 天內到期。此問題的答案有資格獲得 500聲望賞金。 尼爾想引起更多人對這個問題的關注。
當我bundle install在我的 rails 5 專案上運行時,我在似乎具有本機擴展的 gem 上遇到了許多錯誤。這是其中一個寶石的輸出頂部:
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
I also referenced this Go Rails guide, specifically the "Final Steps" section that deals with gems that require C extensions, but that command seems to not apply because I didn't migrate my macOS from Mojave.
At this point I'm not sure what to try next. Ultimately: it appears the issue revolves around being unable to install gems that require C extensions.
Environment:
- macOS Monterey version
12.2 - Using rvm with ruby version
2.7.4 - Project is using rails version
5.0.1
uj5u.com熱心網友回復:
事實證明,問題在于Gemfile.lock檔案中,它被鎖定為使用舊版本的bundler. 我們只是洗掉了Gemfile.lock,然后重新運行bundle以重新生成Gemfile.lock。那解決了它。它現在在Gemfile.lock檔案的底部這樣寫,所以它喜歡這個版本的 bundler:
BUNDLED WITH
2.3.9
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/446740.html
標籤:ruby-on-rails ruby macos macos-monterey
