如何在约塞米蒂10.10上安装therubyracer gem?

如何在约塞米蒂10.10上安装therubyracer gem?,ruby,gem,rubygems,Ruby,Gem,Rubygems,我没有在约塞米蒂10.10上安装Rubyracer 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

我没有在约塞米蒂10.10上安装Rubyracer 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 11:53$gem安装libv8-v'3.16.14.3'--with-system-v8 使用“--with-system-v8”构建本机扩展 这可能需要一段时间。。。 已成功安装libv8-3.16.14.3 libv8-3.16.14.3的解析文档 安装libv8-3.16.14.3的ri文档 0秒后完成libv8文档的安装 已安装1个gem 02:05$gem安装therubyracer-v'0.12.1'--带-system-v8 使用“--with-system-v8”构建本机扩展 这可能需要一段时间。。。 错误:安装Robyracer时出错: 错误:无法生成gem本机扩展。 /usr/local/var/rbenv/versions/2.1.2/bin/ruby extconf.rb——with-system-v8 正在-lpthread中检查main()。。。对 正在-lobjc中检查main()。。。对 正在检查v8.h。。。不 ***extconf.rb失败*** 由于某些原因无法创建Makefile,可能缺少必要的 库和/或标题。有关详细信息,请查看mkmf.log文件。你可以 需要配置选项。 提供的配置选项: --使用opt dir --不带opt dir --选择包含 --不带opt include=${opt dir}/include --使用opt lib --不带opt lib=${opt dir}/lib --用make prog --没有make prog --srcdir=。 --库尔迪尔 --ruby=/usr/local/var/rbenv/versions/2.1.2/bin/ruby --使用pthreadlib --没有pthreadlib --使用objclib --没有objclib --启用调试 --禁用调试 --带-v8-dir --不带-v8-dir --带-v8-include --不带-v8-include=${v8 dir}/include --使用-v8-lib --不带-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:“配置”中:您已选择使用系统上的V8版本(libv8::location::system::NotFoundError) 而不是和libv8 rubygem捆绑在一起的那个。然而, 找不到它。请确保您有一个版本的 已安装与3.16.14.3兼容的v8。你可以 如果是非标准配置,则需要使用特殊--with-v8-dir选项 位置 谢谢 管理 从/usr/local/var/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.3/lib/libv8.rb:7:“configure_makefile”中 来自extconf.rb:32:in`' extconf失败,退出代码1 Gem文件仍将安装在/usr/local/var/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/therubyracer-0.12.1中以供检查。 结果记录到/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
他们在libv8的最新版本中纠正了这个问题。见:

您应该从github repo进行安装,在rails中,我在gemfile中添加了一行内容,如下
gem“libv8”,git:git://github.com/cowboyd/libv8.git,子模块:true

编辑:

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

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)上工作的唯一方式

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

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

Mac OS Catalina的更新:

brew tap homebrew/versions
brew install v8@3.15
brew link --force v8@3.15
gem install libv8 -v 'XX.XX.XX' -- --with-system-v8
gem install therubyracer

也许它对某些人有用,但我在安装RubyRacer时遇到了问题(因为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

我希望这对某人有帮助

我在约塞米蒂也有同样的问题。我的解决方案与上面出现的类似

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

将rubyracer保留在GEM文件中,但删除对libv8的任何显式引用

运行
捆绑安装


libv8作为一个依赖项安装得很好

rm Gemfile.lock

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


我运行的是约塞米蒂10.10

这似乎已经在上游修复了。对我和@aurels、@Mike Causer和@Juanda有效的是:

bundle update libv8
我做了以下几件事

gem install therubyracer
它现在安装了Rubyracer 0.12.1,它安装了依赖项libv8(3.16.14.7 x86_64-darwin-14),安装时没有错误

我使用ruby 2.1.5实现了这一点,我通过以下方式安装了ruby 2.1.5:

CC=/usr/bin/gcc rbenv install 2.1.5
我在运行
brew升级ruby builds
后执行了此操作

在安装了ruby 2.1.5之后,我还运行了

gem upgrade --system

要在尝试简单升级ruby几个小时后获得rubygems更新2.4.5

,请执行以下操作:

brew install ruby 
然后将以下内容添加到gem文件:

gem 'libv8'  
gem 'therubyracer' 

这也是由于与libv8存在一些冲突而导致的,不过您可以只为rubyracer分配一个版本,然后安装它:

在文件中更改以下内容:

宝石“therubyracer”,“~>0.12.1”


根据下面的评论,安装适合我的bundle


是删除Gemfile.lock,然后运行bundle安装

这在我的Yosemite和Ruby 2.1.5(Ruby到RVM)上运行得非常好


早些时候,它给了我一个错误
Gem::Ext::BuildError:error:未能构建Gem本机扩展。
对于libv8 Gem版本3.16.14.3

只有在我的约塞米蒂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

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

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

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

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
看见
rvm list
rvm uninstall ruby-x.x.x
rvm install ruby-x.x.x
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 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/
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