宝石安装libv8 - 版本'3.11.8.17'在ruby(windows)上

时间:2013-05-13 04:13:27

标签: ruby-on-rails libv8

问题如下。

Error installing libv8:
ERROR: Failed to build gem native extension.

    D:/Ruby193/bin/ruby.exe extconf.rb
    creating Makefile
    The system can not find the specified path

        D:Ruby193/lib/ruby/gems/1.9.1/gems/libv8-3.11.8.17/ext/libv8/builder.rb:49:in'setup_python!':libv8 requires python 2 to be installed in order to build,but it is currently not available (RuntimeError)
             from D:Ruby193/lib/ruby/gems/1.9.1/gems/libv8-3.11.8.17/ext/libv8/builder.rb:35:in 'block in build_libv8!'
             from D:Ruby193/lib/ruby/gems/1.9.1/gems/libv8-3.11.8.17/ext/libv8/builder.rb:34:in 'chdir'
             from D:Ruby193/lib/ruby/gems/1.9.1/gems/libv8-3.11.8.17/ext/libv8/builder.rb:34:in 'build_libv8!'
             from D:Ruby193/lib/ruby/gems/1.9.1/gems/libv8-3.11.8.17/ext/libv8/builder.rb:34:in 'install!'
             from extconf.rb:7: in '<main>'
I have installed the python27 and add the path.

python --version
Python 2.7.4

然后我检查代码如下。

 def setup_python!
      # If python v2 cannot be found in PATH,
      # create a symbolic link to python2 the current directory and put it
      # at the head of PATH. That way all commands that inherit this environment
      # will use ./python -> python2
      if python_version !~ /^2/
        unless system 'which python2 2>&1 > /dev/null'
          fail "libv8 requires python 2 to be installed in order to build, but it is currently #{python_version}"
        end
        `ln -fs #{`which python2`.chomp} python`
        ENV['PATH'] = "#{File.expand_path '.'}:#{ENV['PATH']}"
      end
    end

我尝试将Linux命令行安装到windows,以便'ln -fs'应该正常工作。但问题仍然无法解决。

8 个答案:

答案 0 :(得分:162)

试试这个:

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

这个错误很痛苦,直到我运行上面的命令:)

答案 1 :(得分:11)

尝试使用https://github.com/eakmotion/therubyracer_for_windows。我使用这个解决方案在我的Windows机器上解决了同样的问题。

答案 2 :(得分:4)

请按照以下步骤操作:

  1. http://python.org/download/
  2. 获取合适的Python
  3. 使用此命令设置路径SET PATH=<ruby directory>;<python directory>(例如SET PATH=C:\Ruby192\bin;C:\Python27
  4. 现在安装你的欲望宝石

    gem install libv8
    

    here获得此解决方案。

    我想知道你是否因版本而收到此错误。试试这个:

    gem install libv8 --version 3.11.8.0 
    

答案 3 :(得分:2)

确保您可以在系统上实际运行“which”命令。它不是Windows原生的。

如果安装了DevKit或RailsInstaller,则应安装

which”。但是,我也遇到了这个问题(我也安装了许多版本的python并且正在工作),并且在which下发现了我的DevKit...命令(以及RailsInstaller下的那个... )实际上并没有工作。

相近的窗口是“where”。因此,您应该运行“WHERE which”以查明您的系统上是否有“which”命令。

这不会使'therubyracer'工作,或libv8的问题消失,但它是这个难题的一部分。

(我已经将问题发布到msysGit人员,看看他们对非执行'which'命令的看法。)

答案 4 :(得分:0)

我可能会读错了,但我认为问题就在这一行:

unless system 'which python2 2>&1 > /dev/null'

它正在寻找python2,实际上python的命令只是python

也许尝试将python别名化为python2

答案 5 :(得分:0)

执行:gem install rmagick -v '2.13.2'

然后执行:gem install libv8 -v 3.11.8.17 -- --with-system-v8

答案 6 :(得分:0)

此错误与libv8-3.11.8.17 \ ext \ libv8 \ builder.rb脚本有关。 在第60行,我们可以看到这段代码:

`python -c 'import platform; print(platform.python_version())'`.chomp

这是Windows中错误的python命令语法。您应该使用双引号,如下所示:

`python -c "import platform; print(platform.python_version())"`.chomp

修复此脚本后,您应该使用“-l”(仅限本地)键运行gem install。如果不这样做,gem将再次下载带有错误的脚本。

答案 7 :(得分:0)

以下步骤我需要采取以下步骤才能让therubyracer在Windows上运行:

1)安装Python 2.7

2)到这里https://github.com/eakmotion/therubyracer_for_windows并按照说明

3)在Gemfile&amp;中评论therubyracer gem运行Bundle install

#gem 'therubyracer'

4)在Gemfile&amp; amp;中取消注释gem thermubyracer。运行Bundle install

gem 'therubyracer'