therubyracer-Gem::Ext::BuildError:错误:无法生成Gem本机扩展

therubyracer-Gem::Ext::BuildError:错误:无法生成Gem本机扩展,ruby,gcc,osx-mavericks,therubyracer,libv8,Ruby,Gcc,Osx Mavericks,Therubyracer,Libv8,我正在尝试在Mavericks上安装以下gem版本 libv8(3.16.14.3) 瑟鲁比拉克(0.12.1) 显然,Rubyracer gems依赖于libv8 1) 安装libv8 什么是libv8?我的一点研究似乎表明这是谷歌Chrome使用的某种javascript库 我在安装它时遇到了麻烦,但是我有我的错误和一个关于如何绕过它的很好解释的答案 所以我安装了libv8 gem install libv8 -- --with-system-v8 据我所知,这将安装gem,但使用我的

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

  • libv8(3.16.14.3)
  • 瑟鲁比拉克(0.12.1)
显然,Rubyracer gems依赖于libv8

1) 安装libv8 什么是libv8?我的一点研究似乎表明这是谷歌Chrome使用的某种javascript库

我在安装它时遇到了麻烦,但是我有我的错误和一个关于如何绕过它的很好解释的答案

所以我安装了
libv8

gem install libv8 -- --with-system-v8
据我所知,这将安装gem,但使用我的本地系统安装的v8库,而不是。。。宝石随附的版本?不管怎样,它都是成功的

2) 安装therubyracer 在下一步中,我安装therubyracer时遇到了问题。我不太确定这个gem是做什么的,只是它是我试图
捆绑安装的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
Gem::Ext::BuildError:错误:无法生成Gem本机扩展。
/Users/jeeves.butler/.rvm/rubies/ruby-1.9.2-p290/bin/ruby-extconf.rb
正在-lpthread中检查main()。。。对
正在-lobjc中检查main()。。。对
正在检查v8.h。。。不
***extconf.rb失败***
由于某些原因无法创建Makefile,可能是缺少
必要的库和/或标题。查看mkmf.log文件了解更多信息
细节。您可能需要配置选项。
提供的配置选项:
--使用opt dir
--选择包含
--不带opt include=${opt dir}/include
--使用opt lib
--不带opt lib=${opt dir}/lib
--用make prog
--没有make prog
--srcdir=。
--库尔迪尔
--ruby=/Users/jeeves.butler/.rvm/rubies/ruby-1.9.2-p290/bin/ruby
--使用pthreadlib
--没有pthreadlib
--使用objclib
--没有objclib
--启用调试
--禁用调试
--带-v8-dir
--不带-v8-dir
--带-v8-include
--不带-v8-include=${v8 dir}/include
--使用-v8-lib
--不带-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
“配置”:您已选择使用找到的V8版本
在您的系统上(Libv8::Location::system::NotFoundError)
而且*不是*与libv8 rubygem捆绑在一起的那个。然而,
找不到它。请确保您有一个版本的
已安装与3.16.14.3兼容的v8。你可以
如果是非标准配置,则需要使用特殊--with-v8-dir选项
位置
谢谢
管理
来自/Users/jeeves.butler/.rvm/gems/ruby-1.9.2-p290/gems/libv8-3.16.14.3/lib/libv8.rb:7:in“configure_makefile”
来自extconf.rb:32:in`'
extconf失败,退出代码1
Gem文件仍将安装在/Users/jeeves.butler/.rvm/gems/ruby-1.9.2-p290/gems/therubyracer-0.12.1中以供检查。
结果记录到/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
,但现在无法找到本地安装

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

编辑:

  • 我尝试卸载libv8并通过
    brew安装重新安装。在几个类似的问题中也提到了这一点。不走运

  • 我还尝试了所述的
    CC
    CXX
    CPP
    环境变量,尽管我认为这没有任何效果,因为它已经在使用我的
    gcc v4.6
    编译器


  • 尝试先卸载libv8gem,然后安装rubyracer,然后安装libv8

    gem uninstall libv8
    gem install therubyracer
    gem install libv8 -- --with-system-v8
    

    我找到了解决上述问题的方法

    这更像是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版,一切正常


    我当前的操作系统:Mavericks

    这个步骤对我来说很有效

    rvm install 2.2.2
    gem install rails
    bundle install
    
    OS:特立独行 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
    

    上述答案对我来说并不适用;已启用
    禁用共享gems
    ,这会导致其他问题

    我使用的是Yosemite 10.10.1、Rails 3.2.x和Ruby 1.9.3p550

    我的中的以下代码片段为我解决了这个问题

    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
    

    在打破我的头将近两天之后,这对我来说很有效

    rvm install 2.2.2
    gem install rails
    bundle install
    
    在尝试了各自和此处提出的所有其他解决方案后,解决方案为我解决了问题。
    我有完全相同的系统配置。
    这是关于el capitan的,所以不是问题的确切答案,但人们可能会发现这些信息很有用

    我在这里引用它是为了可见性:

    解决了同样的问题

    • MacOS 10.11.2
    • ruby 1.9.3
    • libv8 3.16.14.13
    • therubyracer 0.12.2
    --

    如果您也无法安装libv8

    gem install libv8 --with-system-v8
    

    bundle config build.libv8 --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
    
    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安装gcc
    ,但我不确定这是否真的有必要。

    我刚刚运行了bundle update,它对我很有效

    rvm install 2.2.2
    gem install rails
    bundle install
    

    Obs.:使用Ruby 2.3.0时,我注意到当我们遇到问题时:

    Gem::Ext::BuildError: ERROR: Failed to build gem native extension
    
    然后您应该安装build-essential

    sudo apt install build-essential
    

    它适用于我的mini_race安装问题。

    我在MacOS Mojave 10.14.2上遇到了这个问题
    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)
    
    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 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