安装libv8时出错:错误:无法构buildgem本机扩展

我做了一个铁轨项目,

rails new test_bootstrap. 

成功了。

转移到项目目录并添加了gem

 gem "therubyracer" gem "less-rails" #Sprockets (what Rails 3.1 uses for its asset pipeline) supports LESS gem "twitter-bootstrap-rails" 

并运行

 bundle install 

之后,我有这个错误。

 Installing libv8 (3.16.14.3) Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. c:/RailsInstaller/Ruby1.9.3/bin/ruby.exe extconf.rb creating Makefile 지정된 경로를 찾을 수 없습니다. 지정된 경로를 찾을 수 없습니다. 지정된 경로를 찾을 수 없습니다. c:/RailsInstaller/Ruby1.9.3/lib/ruby/ge ms/1.9.1/gems/libv8-3.16.14.3/ext/libv8/builder.rb:58:in `setup_python!': libv8 requires python 2 to be installed in order to build, but it is currently not available (RuntimeErr or) from c:/RailsInstaller/Ruby1.9. 3/lib/ruby/gems/1.9.1/gems/libv8-3.16.14.3/ext/libv8/builder.rb:42:in `block in build_lib v8/builder.rb:42:in `block in build_libv8!' from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/libv8-3.16.14.3/ext/lib v8/builder.rb:40:in `chdir' from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/libv8-3.16.14.3/ext/lib v8/builder.rb:40:in `build_libv8!' from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/libv8-3.16.14.3/ext/lib v8/location.rb:24:in `install!' from extconf.rb:7:in `<main>' Gem files will remain installed in c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/l ibv8-3.16.14.3 for inspection. Results logged to c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/libv8-3.16.14.3/ex t/libv8/gem_make.out An error occurred while installing libv8 (3.16.14.3), and Bundler cannot continue. Make sure that `gem install libv8 -v '3.16.14.3'` succeeds before bundling. 

对于一些韩国人感到抱歉。 它说,它找不到所select的path或类似的东西。

我试图运行这个命令

 gem install libv8 -v '3.16.14.3' 

抛出相同的错误。

试试这个:

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

注意:因为libv8是therubyracer使用的V8引擎的接口,所以即使已经安装了V8,也可能需要使用libv8。 如果您希望使用自己的V8安装,而不是为您自己构build,请使用--with-system-v8选项。

更多的你可以通过github上的libv8文档

如何解决libv8 / therubyracer问题

我遇到类似的问题,安装libv8后,安装therubyracer时发生错误。 这是我的解决scheme:

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

– 查看错误安装therubyracer –

 $ gem uninstall libv8 $ brew install v8 $ gem install therubyracer $ bundle install 

– 请参阅安装libv8错误 –

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

用自制软件,这有助于我解决这个错误。

 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 

看rubyracer Github问题。

我尝试了上面列出的解决scheme,看起来对于安装单个gem来说很好,但是对于bundler用户来说,你应该使用bundle config

使用

 bundle config build.libv8 --with-system-v8 

 bundle config build.therubyracer --with-system-v8 

configuration捆绑器以在安装特定的gem时使用参数

我不认为你需要therubyracer上的therubyracergem。 这是一个使用V8引擎的JavaScript运行时。 因此它正在尝试安装libv8

您可以安全地从您的Gemfile中删除gem。

Rails很高兴使用它可以find的运行时。 execjsnodejs等都是可能的select。

微软已经在Windows上embedded了JavaScript的JScript运行时,Rails使用它。 看到这更多

解决问题的其他解决方法是将它们分离在Gemfile中

 group :production do gem 'libv8', '~> 3.11.8.3' gem 'therubyracer', :platform => :ruby end 

然后运行捆绑命令: 捆绑安装 – 不生产

我也无法安装这个gem,而不是使用

 --with-system-v8 

一旦尝试做更新 ,为我工作得很好

我的问题与therubyracer没有任何关系,只是libv8 gem,而@ rishav-bhardwaj指出--with-system-v8没有做到这一点,而是我必须执行

bundle update

然后

bundle install

最后

Bundle complete!

错误消失了!

Gem::Ext::BuildError: ERROR: Failed to build gem native extension. An error occurred while installing libv8 (3.16.14.7), and Bundler cannot continue. Make sure that `gem install libv8 -v '3.16.14.7'` succeeds before bundling.

尝试

gem“therubyracer”,“〜> 0.10.2”到Gemfile

它会安装依赖的gem libv8(3.3.10.4),并解决了构buildgem本地扩展失败的问题。

这对我行得通。 把它放在你的Gemfile中

gem'libv8','〜> 3.16.14.7'

使用下面的命令解决了libv8 3.16.14.7问题:

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

然后bundle install成功完成。

我觉得这与libv8有关,而且与therubyracer有关。

我在Rails应用上运行一个bundle安装的时候收到了同样的错误。 如果你遇到过类似的情况,试着在bundle外面安装gem,像这样:

gem install therubyracer

然后运行软件包安装。 我希望这也适用于你。