如何在10.10 Yosemite上安装therubyracer gem?

时间:2014-06-06 12:07:17

标签: ruby gem rubygems

我无法在Yosemite 10.10上安装therubyracer gem。

这是日志:

11:53  $ gem install libv8 -v '3.16.14.3' -- --with-system-v8


Building native extensions with: '--with-system-v8'
This could take a while...
Successfully installed libv8-3.16.14.3
Parsing documentation for libv8-3.16.14.3
Installing ri documentation for libv8-3.16.14.3
Done installing documentation for libv8 after 0 seconds
1 gem installed


02:05  $ gem install therubyracer -v '0.12.1' -- --with-system-v8


Building native extensions with: '--with-system-v8'
This could take a while...
ERROR:  Error installing therubyracer:
    ERROR: Failed to build gem native extension.

    /usr/local/var/rbenv/versions/2.1.2/bin/ruby extconf.rb --with-system-v8
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
    --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=/usr/local/var/rbenv/versions/2.1.2/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
/usr/local/var/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/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 bundle 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 /usr/local/var/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.3/lib/libv8.rb:7:in `configure_makefile'
    from extconf.rb:32:in `'

extconf failed, exit code 1

Gem files will remain installed in /usr/local/var/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/therubyracer-0.12.1 for inspection.
Results logged to /usr/local/var/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/extensions/x86_64-darwin-14/2.1.0-static/therubyracer-0.12.1/gem_make.out

18 个答案:

答案 0 :(得分:246)

gem uninstall libv8
brew install v8
gem install therubyracer
gem install libv8 -v '3.16.14.3' -- --with-system-v8

这是它在10.10(ruby 2.1.2)上为我工作的唯一方式

或尝试gem install libv8 -v 'XX.XX.XX' -- --with-system-v8添加gem的版本:)

答案 1 :(得分:68)

git clone https://github.com/cowboyd/libv8.git
cd libv8
bundle install
bundle exec rake clean build binary
gem install pkg/libv8-3.16.14.3-x86_64-darwin-12.gem #note that libv8 version may change, so tab through files in pkg/, also remember to use the one with version specified

然后只是捆绑你的项目宝石

这是它在10.10(ruby 2.1.2)上为我工作的唯一方式

答案 2 :(得分:37)

这次没有一个答案对我有用。我也用过这个:

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

看到红宝石Github问题。

希望它可以帮助别人。

答案 3 :(得分:25)

也许这对某人有用,但我在安装therubyracer时遇到问题(由于libv8存在问题)解决方案是卸载我安装的所有libv8。安装therubyracer

$ gem uninstall libv8
$ gem install therubyracer -v '0.12.0'
Fetching: libv8-3.16.14.7-x86_64-darwin-14.gem ( 57%)
Fetching: libv8-3.16.14.7-x86_64-darwin-14.gem (100%)
Successfully installed libv8-3.16.14.7-x86_64-darwin-14
Building native extensions.  This could take a while...
Successfully installed therubyracer-0.12.0
2 gems installed

我希望这有助于某人。

答案 4 :(得分:12)

似乎这已在上游修复。对我和@aurels以及@Mike Causer和@Juanda有用的是:

bundle update libv8

答案 5 :(得分:7)

这对我的Yosemite和Ruby 2.1.5(Ruby to RVM)非常有用

gem install libv8 -v '3.16.14.3' -- --with-system-v8

之前它给了我libv8 gem version 3.16.14.3

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

答案 6 :(得分:6)

我可以在rm Gemfile.lock

之后继续使用红宝石赛车

事先: 我通过brew install v8安装了v8,然后执行了gem install libv8 -v '3.16.14.3' -- --with-system-v8

我正在运行10.10 Yosemite

答案 7 :(得分:5)

在我的Yosemite,Ruby 2.1.2中只有这个适用于我:

gem install libv8 -v '3.16.14.3' -- --with-system-v8
brew link --overwrite v8-315 --force
gem install therubyracer -v '0.12.2' -- --with-system-v8

答案 8 :(得分:4)

他们已在最新版本的libv8中更正了此问题。请参阅:https://github.com/cowboyd/libv8/issues/123

您应该从github repo安装,在rails中我添加了一行到我的gemfile,如gem "libv8", git: "git://github.com/cowboyd/libv8.git", submodules: true

编辑:

这显然只能解决一些问题。我安装了新版本的libv8,但现在rubyracer还在寻找另一个我认为的?还在调查。

答案 9 :(得分:3)

我在优胜美地遇到了同样的问题。我的解决方案与上面的解决方案类似。

使用gem uninstall libv8删除可能安装的任何内容。

在您的Gemfile中保留therubyracer,但删除对libv8的任何显式引用。

运行bundle install

然后,libv8作为依赖项安装得很好。

答案 10 :(得分:2)

更新了2018年的答案。

我在High Sierra,在Homebrew 1.6.1

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@3.15/

对我有用。

为他的original answer提供@编码 - 上瘾。

答案 11 :(得分:1)

经过几个小时的尝试,只需升级ruby就可以了:

brew install ruby 

然后将以下内容添加到gem文件中:

gem 'libv8'  
gem 'therubyracer' 

答案 12 :(得分:0)

在编码上瘾者的答案时,对我有用的是使用--with-v8-dir=/usr/local/Cellar/v8@3.15/3.15.11.18_1而不是/usr/local/opt/v8-315的本地酿造目录v8。

这在brew install命令Summary的{​​{1}}中可见。

答案 13 :(得分:0)

该解决方案在遵循Jakub Troszok的上述解决方案之后,对我很有效

gem uninstall libv8
gem install therubyracer -v '0.12.1'
    Fetching: libv8-3.16.14.19-x86_64-darwin-18.gem (100%)
    Successfully installed libv8-3.16.14.19-x86_64-darwin-18
    Building native extensions.  This could take a while...
    Successfully installed therubyracer-0.12.1
    Parsing documentation for libv8-3.16.14.19-x86_64-darwin-18
    Installing ri documentation for libv8-3.16.14.19-x86_64-darwin-18
    Parsing documentation for therubyracer-0.12.1
    Installing ri documentation for therubyracer-0.12.1
    Done installing documentation for libv8, therubyracer after 0 seconds
    2 gems installed
gem install libv8 -v '3.16.14.17' -- --with-system-v8  (if the libv8 version required for your project is different from the one installed by rubyracer)
bundle install

答案 14 :(得分:0)

对任何可能遇到我的问题的人提出警告:我最终在RVM中卸载我的ruby版本,然后重新安装它。这似乎使用最新版本的xcode工具中的正确依赖来编译ruby。

rvm list
rvm uninstall ruby-x.x.x
rvm install ruby-x.x.x

答案 15 :(得分:0)

基于以下评论,对我有用的是什么

https://github.com/cowboyd/therubyracer/issues/304#issuecomment-62046085

是删除Gemfile.lock然后运行bundle install

答案 16 :(得分:0)

这也是由于与libv8的一些冲突而发生的,尽管你可以只为rubyracer分配一个版本并将其安装:

更改gemfile中的以下内容:

gem'therubyracer','〜> 0.12.1'

并进行捆绑安装

答案 17 :(得分:0)

我做了以下

gem install therubyracer

现在安装therubyracer 0.12.1,它会安装已安装但没有错误的依赖项libv8 (3.16.14.7 x86_64-darwin-14)

我使用ruby 2.1.5通过以下方式完成此操作:

CC=/usr/bin/gcc rbenv install 2.1.5

我在运行brew upgrade ruby-builds之后做了。

安装ruby 2.1.5后,我也跑了

gem upgrade --system

获取rubygems-update 2.4.5