【问题标题】:Gem therubyracer does not install even if libv8 is installed即使安装了 libv8,Gem therubyracer 也不会安装
【发布时间】:2016-04-09 08:50:04
【问题描述】:

我已经使用这个命令在 Windows 上安装了libv8 gem:

gem install libv8 -- --with-system-v8

然后,当我尝试安装 therubyracer 时,它给了我很长的错误消息:

Installing therubyracer 0.12.2 with native extensions

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory: D:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/therubyracer- 0.12.2/ext/v8
D:/Ruby21-x64/bin/ruby.exe -r ./siteconf20160105-4924-101vdyd.rb extconf.rb
checking for main() in -lpthread... 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=D:/Ruby21-x64/bin/ruby
--with-pthreadlib
--without-pthreadlib
--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
D:/Ruby21-x64/lib/ruby/gems/2.1.0/gems/libv8-3.16.14.13/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.13 installed. You may
need to special --with-v8-dir options if it is in a non-standard
location

thanks,
The Mgmt

我的理解是,therubyracer 想要找到v8。我已经安装了已经拥有它的 Node.js。甚至可以使用它吗?或者对于 therubyracer 还有其他解决方案?

【问题讨论】:

  • 帮不上什么忙,因为我只使用 Linux,但您需要 v8 的“开发”(源)文件。 checking for v8.h... no
  • 正如 Paulo 所说,您需要 v8 的开发版本。如果您尝试运行 @987654329,您可以尝试在您的机器上安装 nodejs 而不是使用 therubyracer 解决这个问题仅限@任务。
  • 我已经从github下载了v8的原始源码,如何安装therubyracer?

标签: ruby-on-rails ruby


【解决方案1】:

此错误出现在 OS X El Capitan 中。 只需将v8@3.15 用于therubyracer

brew install v8@3.15
bundle config --local build.libv8 --with-system-v8
bundle config --local build.therubyracer --with-v8-dir=/usr/local/opt/v8@3.15
bundle install

Check detail of this issue

【讨论】:

  • 感谢这对我很有用。我也收到了这条消息:“在捆绑之前确保 gem install therubyracer -v '0.12.2' 成功。”
  • 我同意,使用 therubyracer 0.12.2 并设置这些捆绑配置选项对我有用。我使用这个选项主要是因为它以一种我可以实际使用 Gemfile 的方式解决了这个问题,并且交易不会在部署时造成任何奇怪的问题
  • Error: No available formula with the name "v8-315"
【解决方案2】:

我也遇到了这个问题,花了很多时间。这对我有用。

$ 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

【讨论】:

    【解决方案3】:

    @sushilprj 的建议很有魅力。

    我只需要运行一个额外的东西,因为我在尝试“brew install v8@3.15”后收到以下消息

    错误:您的用户不可写以下目录: /usr/local/share/man/man5

    您应该将这些目录的所有权更改为您的用户。
    sudo chown -R $(whoami) /usr/local/share/man/man5

    所以,我执行了:

    $sudo chown -R $(whoami) /usr/local/share/man/man5
    

    然后我执行了@sushilprj 建议的 4 个命令。

    【讨论】:

      【解决方案4】:

      确保您需要 therubyracer - 事实证明,对于我们的案例,我们根本不需要它,只是删除它并使用节点 - https://kmitov.com/posts/we-dont-need-therubyracer-and-the-libv8-error-for-compiling-native-extensions/

      【讨论】:

        【解决方案5】:

        在 MacOS Mojave 上可以正常工作:

        1. 安装 v8@3.15

          brew install v8@3.15
          
        2. 编辑个人资料(在我的情况下为vi ~/.zshrc)并添加:

          export PATH="/usr/local/opt/v8@3.15/bin:$PATH"
          export LDFLAGS="-L/usr/local/opt/v8@3.15/lib"
          export CPPFLAGS="-I/usr/local/opt/v8@3.15/include"
          
        3. 在这种情况下安装 ruby​​racer 版本 0.12.2:

          gem install therubyracer -v '0.12.2' -- --with-v8-dir=/usr/local/opt/v8@3.15
          

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2013-10-08
          • 2015-03-26
          • 2012-03-25
          • 2011-04-17
          • 2012-02-26
          • 1970-01-01
          • 2022-01-16
          • 2014-10-31
          相关资源
          最近更新 更多