繁体   English   中英

therubyracer - Gem::Ext::BuildError: 错误:无法构建 gem 本机扩展

[英]therubyracer - Gem::Ext::BuildError: ERROR: Failed to build gem native extension

我正在尝试在 Mavericks 上安装以下 gem 版本

  • libv8 (3.16.14.3)
  • therubyracer (0.12.1)

显然 therubyracer gems 依赖于 libv8。

1)安装libv8

什么是libv8? 我的一些研究似乎表明它是 Google Chrome 使用的某种 javascript 库?

我在安装它时遇到了麻烦,但是这篇很棒的帖子既有我的错误,也有关于如何绕过它的解释清楚的答案。

所以我安装了libv8

gem install libv8 -- --with-system-v8

我的理解是,这会安装 gem,但使用我本地系统安装的 v8 库,而不是……gem 附带的版本? 无论哪种方式,它都是成功的。

2)安装rubyracer

在下一步中,我在安装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 ,但现在无法找到本地安装。

  • 如何检查我是否确实安装了 V8 以及如何找到它?
  • 我尝试了一些指定的标志,它们似乎都没有将 gem 指向正确的安装目录
  • 这可能是一个单独的主题,但什么是extconf.rb 我在几个地方见过。 它特别想用gcc编译器做什么?

谢谢!!

编辑:

  1. 我尝试了这种卸载 libv8 并通过brew install重新安装的解决方案 在几个类似的问题中也提到了这一点。 没运气。

  2. 我还尝试了此处描述的CCCXXCPP环境变量,尽管我认为这没有任何影响,因为它已经在使用我的gcc v4.6编译器。

这些步骤对我有用。

操作系统: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,然后安装 ruby​​racer,然后安装 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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM