![](/img/trans.png)
[英]Gem::Ext::BuildError: ERROR: Failed to build gem native extension
[英]therubyracer - Gem::Ext::BuildError: ERROR: Failed to build gem native extension
我正在嘗試在 Mavericks 上安裝以下 gem 版本
顯然 therubyracer gems 依賴於 libv8。
什么是libv8? 我的一些研究似乎表明它是 Google Chrome 使用的某種 javascript 庫?
我在安裝它時遇到了麻煩,但是這篇很棒的帖子既有我的錯誤,也有關於如何繞過它的解釋清楚的答案。
所以我安裝了libv8
gem install libv8 -- --with-system-v8
我的理解是,這會安裝 gem,但使用我本地系統安裝的 v8 庫,而不是……gem 附帶的版本? 無論哪種方式,它都是成功的。
在下一步中,我在安裝therubyracer
gem 時遇到了問題。 我不太確定這個 gem 有什么作用,只是它是我試圖bundle install
的 rails 項目的依賴項。
它給了我以下錯誤:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/Users/jeeves.butler/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb
checking for main() in -lpthread... yes
checking for main() in -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
--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=/Users/jeeves.butler/.rvm/rubies/ruby-1.9.2-p290/bin/ruby
--with-pthreadlib
--without-pthreadlib
--with-objclib
--without-objclib
--enable-debug
--disable-debug
--with-v8-dir
--without-v8-dir
--with-v8-include
--without-v8-include=${v8-dir}/include
--with-v8-lib
--without-v8-lib=${v8-dir}/lib
/Users/jeeves.butler/.rvm/gems/ruby-1.9.2-p290/gems/libv8-3.16.14.3/ext/libv8/location.rb:50:in
'configure': You have chosen to use the version of V8 found
on your system (Libv8::Location::System::NotFoundError)
and *not* the one that is bundled with the libv8 rubygem. However,
it could not be located. please make sure you have a version of
v8 that is compatible with 3.16.14.3 installed. You may
need to special --with-v8-dir options if it is in a non-standard
location
thanks,
The Mgmt
from /Users/jeeves.butler/.rvm/gems/ruby-1.9.2-p290/gems/libv8-3.16.14.3/lib/libv8.rb:7:in `configure_makefile'
from extconf.rb:32:in `<main>'
extconf failed, exit code 1
Gem files will remain installed in /Users/jeeves.butler/.rvm/gems/ruby-1.9.2-p290/gems/therubyracer-0.12.1 for inspection.
Results logged to /Users/jeeves.butler/.rvm/gems/ruby-1.9.2-p290/extensions/x86_64-darwin-13/1.9.1/therubyracer-0.12.1/gem_make.out
據我所知,我選擇使用本地 V8 庫安裝libv8
而不是libv8
提供的libv8
,但現在無法找到本地安裝。
extconf.rb
? 我在幾個地方見過。 它特別想用gcc
編譯器做什么?謝謝!!
編輯:
這些步驟對我有用。
操作系統:Maverick Ruby:2.1.1
gem uninstall libv8
gem install therubyracer -v '0.11.3'
gem install libv8 -v '3.11.8.13' -- --with-system-v8
對於那些在 OS X El Capitan 中遇到這個問題的人來說,來自 therubyracer 問題線程的這個解決方案最終對我有用:
brew tap homebrew/versions
brew install v8-315
gem install libv8 -v '3.16.14.13' -- --with-system-v8
gem install therubyracer -- --with-v8-dir=/usr/local/opt/v8-315
bundle install
我之前也運行過brew install gcc
,但我不確定這是否真的有必要。
嘗試先卸載 libv8 gem,然后安裝 rubyracer,然后安裝 libv8
gem uninstall libv8
gem install therubyracer
gem install libv8 -- --with-system-v8
在嘗試了在各自的github 問題和此處提出的所有其他解決方案之后, Tertom 在 github 上發布的解決方案為我解決了這個問題。
我有完全相同的系統配置。
這是在 el capan 上,所以不是問題的確切答案,但人們可能會發現此信息有幫助。
我在這里引用它以提高知名度:
解決了同樣的問題
- macOS 10.11.2
- 紅寶石 1.9.3
- libv8 3.16.14.13
- 紅寶石賽車 0.12.2
——
brew tap homebrew/versions brew install v8-315 brew link --force v8-315 bundle install brew unlink v8-315
如果您也無法安裝 libv8,
gem install libv8 --with-system-v8
或者
bundle config build.libv8 --with-system-v8
對於所有使用 macOS 10.15 的人來說,brew 已經發生了變化,因此您需要執行這些命令。
brew install v8@3.15
gem install libv8 -v 'YOUR_VERSION' -- --with-system-v8
gem install therubyracer -v 'YOUR_VERSION' -- --with-v8-dir=/usr/local/opt/v8@3.15
bundle install
以上答案對我不起作用; 我的 bundler 配置啟用了disable-shared-gems
,這會導致其他問題。
我使用的是 Yosemite 10.10.1、Rails 3.2.x 和 Ruby 1.9.3p550。
我的bin/setup
的以下代碼段為我解決了這個問題。
if ! bundle show therubyracer; then
bundle config build.libv8 --with-system-v8
gem install --install-dir vendor/bundle libv8 -v 3.16.14.7
gem install libv8 -v 3.16.14.7
gem install --install-dir vendor/bundle therubyracer
fi
我找到了解決上述問題的方法。
這更多是 libv8 和 therubyracer 之間的兼容性。
gem install libv8 -v '3.3.10.4' -- --with-system-v8
gem install therubyracer -v '0.10.2'
這應該可以正常工作,因為這兩個版本都與我兼容。 最初,我試圖為 therubyracer 安裝 0.12.0 版本,但遇到了這個問題。 切換到 0.10.2 版后,一切正常。
我目前的操作系統:小牛隊
我在MacOS Mojave 10.14.2
遇到了這個問題,當我發現安裝包v8-315
位置以及文件夾名稱是什么時,我能夠解決這個問題。 就我而言,它在這里/usr/local/opt/v8@3.15
。
為了解決這個問題,我運行了下一個:
brew install v8-315
gem install libv8 -v '3.16.14.15' -- --with-system-v
gem install therubyracer -v '0.12.2' -- --with-system-v8 --with-v8-dir=/usr/local/opt/v8@3.15
bundle install
在打破我的頭將近兩天后,這對我有用。
rvm install 2.2.2
gem install rails
bundle install
盡管安裝了 libv8 的 x64(64 位變體),但由於依賴 libv8,我無法在 macOS Catalina 10.15 上構建 therubyracer。
對我來說,解決方案是從 therubyracer 切換到 mini_racer,安裝了 mini_racer gem(無需在本地構建),嘿,快! 我可以繼續。
嘗試一下!
在我的情況下
MacOS: Catalina ,Ruby: 2.3.3 ,使用 rbenv (不是 RVM),我需要 therubyracer 版本:0.12.3(沒關系)
我嘗試了所有解決方案,但對我有用的方法,親愛的請不要盲目復制粘貼解決方案(bcz 我就是這樣做的),首先閱讀並更改以下命令中的版本(如果需要)。 大多數命令在大多數現有答案中都很常見,但對我gem install therubyracer -- --with-v8-dir=$(brew --prefix v8-315)
而不是gem install therubyracer -- --with-v8-dir=/usr/local/opt/v8-315
感謝Junji Zhi在這個答案中的評論
1. brew install gcc
2. brew tap homebrew/versions (If it wont work then below 2 steps, for latest MacOS version)
2.a. brew tap brewsci/bio
2.b. brew tap brewsci/science
3. brew install v8-315 (uninstall if v8 installed previously without '-315')
4. gem install libv8 -v '3.16.14.19' -- --with-system-v8 (Be careful with the libv8 version mentioned in this command, replace version number with one required)
5.a. gem install therubyracer -- --with-v8-dir=/usr/local/opt/v8-315 (If it does not work then try below one, In my case below command worked)
5.b. gem install therubyracer -- --with-v8-dir=$(brew --prefix v8-315)
完成,然后繼續bundle install
注意:在 gem install therubyracer 時,檢查正在安裝哪個版本的libv8 ,如果它與我在第 4 步中提到的不同,那么您的 therubyracer 可能無法安裝,所以只需做一件事, gem uninstall libv8
然后重復步驟 - 4通過更改版本,您可以在安裝therubyracer 時在控制台中看到的內容
這對我有用:
gem install libv8 -v '3.16.14.17' -- --with-system-v8
brew install v8-315
gem install therubyracer -v '0.12.3' --source 'http://rubygems.org/' -- --with-v8-dir='/usr/local/opt/v8@3.15'
對於最后一個命令,檢查brew --prefix v8-315
的輸出,在我的情況下它是/usr/local/opt/v8@3.15
。
下面的命令在 Catalina 中使用 bundler 為我解決了這個問題
$ brew install v8@3.15
$ bundle config build.libv8 --with-system-v8
$ bundle config build.therubyracer --with-v8-dir=$(brew --prefix v8@3.15)
$ bundle install
我注意到當我們遇到問題時:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension
然后你應該安裝 build-essential
sudo apt install build-essential
它適用於我的 mini_race 安裝問題。
我只是運行捆綁更新,它對我有用。
觀察:使用 Ruby 2.3.0
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.