捆绑安装/更新:libv8 (therubyracer) 安装失败(使用本机扩展)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8126465/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 02:21:15  来源:igfitidea点击:

bundle install / update: libv8 (therubyracer) installation fails (with native extensions)

ruby-on-railsgem

提问by emrass

I recently wanted to update my gem bundle but ran into installation problems with libv8 (requirement for therubyracer):

我最近想更新我的 gem 包,但遇到了 libv8 的安装问题(therubyracer 的要求):

Installing libv8 (3.3.10.3) with native extensions /usr/local/rvm/rubies/ruby-1.9.3-head/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:552:in `rescue in block in build_extensions': ERROR: Failed
 to build gem native extension. (Gem::Installer::ExtensionBuildError)

        /usr/local/rvm/rubies/ruby-1.9.3-head/bin/ruby extconf.rb 
Checking for Python...*** 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.

I have found the issue report on therubyracer github siteand it suggests to uninstall and reinstall libv8, but this does not work on my Ubuntu 11.04 machine. Any ideas - or am I stuck with the old version for a while?

在 therubyracer github 站点上找到了问题报告,它建议卸载并重新安装 libv8,但这在我的 Ubuntu 11.04 机器上不起作用。任何想法 - 还是我坚持使用旧版本一段时间?

回答by Dmitry Polushkin

Try that one for a little while:

尝试一下:

gem 'therubyracer'
gem 'libv8', '3.16.14.3'

Should help.

应该有帮助。

Also it's better with a new bundler: gem install bundler --pre

使用新的打包器也更好: gem install bundler --pre

回答by Serge Seletskyy

I had a similar issue on my good old Ubuntu 10.04 (x64)

我在旧的 Ubuntu 10.04 (x64) 上遇到了类似的问题

After I updated the project Gemfile had those gems

在我更新项目后,Gemfile 有了这些宝石

  gem 'libv8', '~> 3.11.8'
  gem "therubyracer", '>= 0.11.0beta1', :require => 'v8'

But when I ran 'bundle install' I got an error

但是当我运行“捆绑安装”时出现错误

Installing therubyracer (0.11.0beta1) with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /home/sseletskyy/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb 
checking for main() in -lpthread... yes
creating Makefile

make
compiling array.cc
compiling script.cc
compiling object.cc
compiling constants.cc
compiling signature.cc
compiling value.cc
compiling locker.cc
compiling init.cc
compiling heap.cc
compiling date.cc
compiling message.cc
compiling accessor.cc
compiling context.cc
compiling exception.cc
compiling backref.cc
compiling trycatch.cc
compiling gc.cc
compiling handles.cc
compiling stack.cc
compiling template.cc
compiling function.cc
compiling primitive.cc
compiling rr.cc
compiling v8.cc
compiling invocation.cc
compiling string.cc
compiling external.cc
compiling constraints.cc
linking shared-object v8/init.so
/home/sseletskyy/.rvm/gems/ruby-1.9.3-p194/gems/libv8-3.11.8.2-x86_64-linux/vendor/v8/out/x64.release/obj.target/tools/gyp/libv8_base.a: could not read symbols: No such file or directory
collect2: ld returned 1 exit status
make: *** [init.so] Error 1


Gem files will remain installed in /home/sseletskyy/.rvm/gems/ruby-1.9.3-p194/gems/therubyracer-0.11.0beta1 for inspection.
Results logged to /home/sseletskyy/.rvm/gems/ruby-1.9.3-p194/gems/therubyracer-0.11.0beta1/ext/v8/gem_make.out
An error occured while installing therubyracer (0.11.0beta1), and Bundler cannot continue.
Make sure that `gem install therubyracer -v '0.11.0beta1'` succeeds before bundling.

Here's a list of steps which worked for me to solve that block quickly

这是对我快速解决该问题有用的步骤列表

  1. Uninstall all versions of gems 'libv8' and 'therubyracer'

    > gem uninstall therubyracer

    > gem uninstall libv8

  2. Install therubyracer manually

    > gem install therubyracer

    Fetching: libv8-3.3.10.4-x86_64-linux.gem (100%) Fetching: therubyracer-0.10.1.gem (100%) Building native extensions. This could take a while... Successfully installed libv8-3.3.10.4-x86_64-linux Successfully installed therubyracer-0.10.1 2 gems installed Installing ri documentation for libv8-3.3.10.4-x86_64-linux... Installing ri documentation for therubyracer-0.10.1... Installing RDoc documentation for libv8-3.3.10.4-x86_64-linux... Installing RDoc documentation for therubyracer-0.10.1...

  3. Check versions of installed gems

    > gem list | grep libv

    libv8 (3.3.10.4 x86_64-linux)

    > gem list | grep therubyracer

    therubyracer (0.10.1)

  4. Set those versions in Gemfile and run

    > bundle install

  5. Summary. Well I understand that in my case I used not the latest versions and it could be bad for compatibility sake. But at least I could continue development.

  1. 卸载所有版本的 gems 'libv8' 和 'therubyracer'

    > gem 卸载 therubyracer

    > gem 卸载 libv8

  2. 手动安装 therubyracer

    > gem 安装 therubyracer

    获取:libv8-3.3.10.4-x86_64-linux.gem (100%) 获取:therubyracer-0.10.1.gem (100%) 构建原生扩展。这可能需要一段时间... 成功安装 libv8-3.3.10.4-x86_64-linux 成功安装 therubyracer-0.10.1 2 gems 安装 libv8-3.3.10.4-x86_64-linux 的 ri 文档... 安装 therubyracer 的 ri 文档-0.10.1...为libv8-3.3.10.4-x86_64-linux安装RDoc文档...为rubyracer-0.10.1安装RDoc文档...

  3. 检查已安装 gem 的版本

    > 宝石列表 | grep libv

    libv8 (3.3.10.4 x86_64-linux)

    > 宝石列表 | grep therubyracer

    therubyracer (0.10.1)

  4. 在 Gemfile 中设置这些版本并运行

    > 捆绑安装

  5. 概括。好吧,我知道在我的情况下,我没有使用最新版本,并且出于兼容性考虑可能会很糟糕。但至少我可以继续发展。

回答by rohitkadam19

Ubuntu 11.04

Ubuntu 11.04

gem "therubyracer", '0.11.1'
gem 'libv8'
  1. Uninstall therubyracer and libv8 gem

  2. Update the bundler gem version

  3. Install lib8-dev package

    sudo apt-get install libv8-dev

  4. Then run this

    sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion imagemagick graphicsmagick libmagickcore-dev libmagickwand-dev

  5. Now install therubyracer manually

    gem install therubyracer

  6. It will install therubyracer and libv8 for you.

  7. Now run bundle install

  1. 卸载 therubyracer 和 libv8 gem

  2. 更新 bundler gem 版本

  3. 安装 lib8-dev 包

    须藤 apt-get 安装 libv8-dev

  4. 然后运行这个

    sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion imagemagick graphics libmagickcore-dev libmagickwand-dev

  5. 现在手动安装 therubyracer

    gem 安装 therubyracer

  6. 它将为您安装 therubyracer 和 libv8。

  7. 现在运行捆绑安装

All above steps solved my problem :)

以上所有步骤都解决了我的问题:)

回答by TwoByteHero

I've run into the same issue recently. Here is a bit of helpful information from the RoR.org 'Getting Started with Rails' Guide:

我最近遇到了同样的问题。以下是 RoR.org 的“Rails 入门”指南中的一些有用信息:

Compiling CoffeeScript to JavaScript requires a JavaScript runtime and the absence of a runtime will give you an execjs error. Usually Mac OS X and Windows come with a JavaScript runtime installed. Rails adds the therubyracer gem to Gemfile in a commented line for new apps and you can uncomment if you need it. therubyrhino is the recommended runtime for JRuby users and is added by default to Gemfile in apps generated under JRuby. You can investigate about all the supported runtimes at ExecJS.

将 CoffeeScript 编译为 JavaScript 需要一个 JavaScript 运行时,如果没有运行时,将会出现 execjs 错误。通常 Mac OS X 和 Windows 都安装了 JavaScript 运行时。Rails 在新应用程序的注释行中将 therubyracer gem 添加到 Gemfile,如果需要,您可以取消注释。therubyrhino 是 JRuby 用户推荐的运行时,默认情况下被添加到在 JRuby 下生成的应用程序中的 Gemfile。您可以在 ExecJS 上调查所有支持的运行时。

Based on what I've read elsewhere it seems that Windows support for the therubyracer gem is not there in the '3.3.10.4' version (possibly there in a more recent version, didn't read in that far though). I've installed python 2.7 and got it to compile but you still get errors later during the environment setup process.

根据我在其他地方读到的内容,似乎 Windows 对 therubyracer gem 的支持在“3.3.10.4”版本中不存在(可能在更新的版本中存在,但没有读那么远)。我已经安装了 python 2.7 并对其进行了编译,但稍后在环境设置过程中仍然会出现错误。

So it comes down to this. Check out therubyracer documentation here. 'therubyracer' provides these features (:

所以归结为这一点。在此处查看 therubyracer 文档。'therubyracer' 提供了这些功能(:

  • Evaluate Javascript from with in Ruby
  • Embed your Ruby objects into the Javascript world
  • Manipulate JavaScript objects and call JavaScript functions from Ruby
  • API compatible with the The Ruby Rhino (for JRuby: http://github.com/cowboyd/therubyrhino)
  • 在 Ruby 中使用 with 评估 Javascript
  • 将您的 Ruby 对象嵌入到 Javascript 世界中
  • 操作 JavaScript 对象并从 Ruby 调用 JavaScript 函数
  • 与 The Ruby Rhino 兼容的 API(对于 JRuby:http: //github.com/cowboyd/therubyrhino

If you ABSOLUTELY REQUIRE those features then you should switch to *nix and drop Windows for a development/production environment. Otherwise you can do what I did and choose not to install 'therubyracer' or 'libv8' (removed from my Gemfile). I don't rely heavily on JavaScript with the site I'm experiencing this problem with, so I just ignored both gems and all seems well (so far).

如果您绝对需要这些功能,那么您应该切换到 *nix 并为开发/生产环境删除 Windows。否则你可以做我所做的并选择不安装“therubyracer”或“libv8”(从我的 Gemfile 中删除)。我在遇到这个问题的网站上并不严重依赖 JavaScript,所以我只是忽略了这两个 gem,一切看起来都很好(到目前为止)。

Hope this helps someone else in need!

希望这可以帮助其他有需要的人!

回答by Andrei

Ubuntu 12.04

Ubuntu 12.04

gem 'libv8', '3.11.8.3'
gem 'therubyracer', '0.11.0beta5'

Specifying the versions above solved my problem with therubyracer.

指定上述版本解决了我的 therubyracer 问题。

Also as someone above suggested, I used the latest bundler:

同样正如上面有人建议的那样,我使用了最新的捆绑器:

gem install bundler --pre

回答by sebastianwagner

Be sure to reference rubyin your Gemfile

请务必参考红宝石Gemfile

gem 'therubyracer', :platform => :ruby

and then run bundle update.

然后运行bundle update

回答by user3487016

Using these terminal commands fixed it for me on Ubuntu 16.04

使用这些终端命令在 Ubuntu 16.04 上为我修复了它

sudo apt-get install g++
sudo apt-get install build-essential