如何在10.10 Yosemite上安装therubyracer gem?

Nic*_*nco 92 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

Wyl*_*kon 249

gem uninstall libv8
brew install v8
gem install therubyracer
gem install libv8 -v '3.16.14.3' -- --with-system-v8
Run Code Online (Sandbox Code Playgroud)

这是它在10.10上的唯一方式(ruby 2.1.2)

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

  • 除此之外,如果您使用的是Bundler并拥有Gemfile,则可能需要将其调整为刚刚安装的最新版本.例如,我必须(在OS X Yosemite上)执行以下操作:`gem'therubyracer','0.12.1'`(添加版本).然后删除Gemfile.lock并执行`bundle install`.它工作正常. (4认同)
  • 是的,这是一个没有任何古怪的帮助.即使您可能只是收到libv8错误,请执行此操作!谢谢. (3认同)
  • 在OS X Yosemite中使用Ruby 2.1.3为我工作. (3认同)
  • 这对我有用.优胜美地上的红宝石2.1.5. (3认同)
  • 是的.这是正确的方法.特别是如果您使用最新的10.10命令行工具重建了ruby. (2认同)
  • 这对我来说也适用于El Capitan.我认为这更简单,应该是公认的答案. (2认同)

mml*_*mln 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
Run Code Online (Sandbox Code Playgroud)

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

这是它在10.10上的唯一方式(ruby 2.1.2)

  • 谢谢,但这是libv8,我说的是therubyracer gem. (2认同)
  • 这就是你需要避免使用therubyracer的问题 (2认同)
  • 我不在乎我是否违反规定.我不能够感谢你.你为我节省了一个巨大的项目截止日期. (2认同)
  • 还值得一提的是,如果您使用的是Gemfile并且仍然无法安装therubyracer,那可能是因为已经有一个不同版本的libv8已经添加到Gemfile.lock中了.只需添加`gem'libv8','3.16.14.3''(或者您刚刚手动安装的libv8的确切版本),然后运行bundle update libv8.那应该安装therubyracer. (2认同)

cod*_*ted 38

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

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
Run Code Online (Sandbox Code Playgroud)

看到红宝石Github问题.

希望它可以帮助别人.

  • 实际上,“gem install therubyracer -- --with-v8-dir=$(brew --prefix v8-315)”对我来说效果更好。我的 mac 中的目录实际上是 `/usr/local/opt/v8@3.15` (2认同)

Jak*_*zok 26

也许它会对某人有用但我在安装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
Run Code Online (Sandbox Code Playgroud)

我希望这可以帮助别人.


Mar*_* T. 13

看起来这已经在上游修复了.对我和@aurels以及@Mike Causer和@Juanda有用的是:

bundle update libv8
Run Code Online (Sandbox Code Playgroud)


Roh*_*ini 7

这对我的Yosemite和Ruby 2.1.5(Ruby通过RVM)非常有用.

gem install libv8 -v '3.16.14.3' -- --with-system-v8
Run Code Online (Sandbox Code Playgroud)

之前它给了我Gem::Ext::BuildError: ERROR: Failed to build gem native extension.libv8 gem版本3.16.14.3的错误


Clo*_*ick 6

我之后能够继续使用红宝石赛车 rm Gemfile.lock

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

我正在跑10.10优胜美地


aqu*_*ach 6

只有这在我的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
Run Code Online (Sandbox Code Playgroud)