ruby 如何在 10.10 Yosemite 上安装 therubyracer gem?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24081473/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to install therubyracer gem on 10.10 Yosemite?
提问by Nicolas Blanco
I don't manage to install therubyracer gem on Yosemite 10.10.
我无法在 Yosemite 10.10 上安装 therubyracer gem。
Here is the log:
这是日志:
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
采纳答案by mmln
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
then just bundle your project gems
然后只需捆绑您的项目宝石
this is the only way it worked for me on 10.10 (ruby 2.1.2)
这是它在 10.10 (ruby 2.1.2) 上对我有用的唯一方法
回答by Wylkon
gem uninstall libv8
brew install v8
gem install therubyracer
gem install libv8 -v '3.16.14.3' -- --with-system-v8
this is the only way it worked for me on 10.10 (ruby 2.1.2)
这是它在 10.10 (ruby 2.1.2) 上对我有用的唯一方法
Or try gem install libv8 -v 'XX.XX.XX' -- --with-system-v8adding the version of the gem :)
或者尝试gem install libv8 -v 'XX.XX.XX' -- --with-system-v8添加 gem 的版本:)
UPDATE for Mac OS Catalina:
Mac OS Catalina 更新:
brew tap homebrew/versions
brew install [email protected]
brew link --force [email protected]
gem install libv8 -v 'XX.XX.XX' -- --with-system-v8
gem install therubyracer
回答by coding addicted
None of the answers work for me this time. I have too use this:
这次没有一个答案对我有用。我也用过这个:
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
Seen on the rubyracer Github issues.
在 rubyracer Github 问题上看到。
Hope it helps someone else.
希望它可以帮助别人。
回答by Jakub Troszok
Maybe it will be useful for someone but I had problems installing therubyracer (because of the problems with libv8) the solution was to uninstallall the libv8 that I had installed. Install therubyracer
也许它对某人有用,但我在安装 therubyracer 时遇到了问题(因为 libv8 的问题),解决方案是卸载我安装的所有 libv8。安装 rubyracer
$ 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
I hope this helps someone.
我希望这可以帮助别人。
回答by Martin T.
It seems like this has been fixed upstream. What worked for me and @aurels and @Mike Causer and @Juanda was:
这似乎已在上游修复。对我、@aurels、@Mike Causer 和@Juanda 有用的是:
bundle update libv8
回答by Rohan Daxini
This worked for me very well on my Yosemite and Ruby 2.1.5 (Ruby through RVM)
这对我的 Yosemite 和 Ruby 2.1.5(Ruby 到 RVM)非常有效
gem install libv8 -v '3.16.14.3' -- --with-system-v8
Earlier it was giving me error Gem::Ext::BuildError: ERROR: Failed to build gem native extension.for libv8 gem version 3.16.14.3
早些时候它给了我Gem::Ext::BuildError: ERROR: Failed to build gem native extension.libv8 gem 版本 3.16.14.3 的错误
回答by aquajach
Only this works for me in my Yosemite, Ruby 2.1.2:
在我的优胜美地 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
回答by CloudMagick
I was able to proceed with ruby racer after rm Gemfile.lock
之后我能够继续使用 ruby Racer rm Gemfile.lock
beforehand:
I installed v8 via brew install v8, and then did gem install libv8 -v '3.16.14.3' -- --with-system-v8
事先:我通过 安装了 v8 brew install v8,然后做了gem install libv8 -v '3.16.14.3' -- --with-system-v8
and I am running 10.10 Yosemite
我正在运行 10.10 Yosemite
回答by Borromakot
They have corrected this issue in the most recent version of libv8. See: https://github.com/cowboyd/libv8/issues/123
他们在最新版本的 libv8 中更正了这个问题。参见:https: //github.com/cowboyd/libv8/issues/123
You should install from the github repo, in rails I added a line to my gemfile like this gem "libv8", git: "git://github.com/cowboyd/libv8.git", submodules: true
您应该从 github 存储库安装,在 Rails 中,我像这样在我的 gemfile 中添加了一行 gem "libv8", git: "git://github.com/cowboyd/libv8.git", submodules: true
EDIT:
编辑:
This apparently only solves some of the problem. I installed the new version of libv8, but now the rubyracer is still looking for the other one I think? Still looking into it.
这显然只能解决部分问题。我安装了新版本的 libv8,但现在 rubyracer 还在寻找我认为的另一个?还在研究它。
回答by Martin Streicher
I had the same issue on Yosemite. My solution is similar to what appears above.
我在优胜美地遇到了同样的问题。我的解决方案与上面出现的类似。
Use gem uninstall libv8to remove anything that might be installed.
使用gem uninstall libv8删除任何可能被安装。
Leave therubyracer in your Gemfile, but remove any explicit reference to libv8.
将 therubyracer 留在您的 Gemfile 中,但删除对 libv8 的任何显式引用。
Run bundle install.
运行bundle install。
libv8 then installed fine as a dependency.
libv8 然后作为依赖安装得很好。

