【问题标题】:gem install libv8 --version '3.11.8.17' on ruby (windows)gem install libv8 --version '3.11.8.17' on ruby​​ (windows)
【发布时间】:2013-05-07 01:21:14
【问题描述】:

问题如下。

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'应该可以工作。但问题仍然无法解决。

【问题讨论】:

  • 嗨.. 添加 libv8 liberey Window 非常棘手,因为 window 不支持 libv8 。我也有同样的问题,所以我切换到 linux/Ubuntu。
  • 非常感谢,我会换成linux的。
  • 虽然这不是问题的实际解决方案...@iscube1

标签: ruby-on-rails libv8


【解决方案1】:

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

【解决方案2】:

为了让 therubyracer 在 Windows 上工作,我必须采取以下步骤:

1) 安装 Python 2.7

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

3) 在 Gemfile 中注释 therubyracer gem & Run Bundle install

#gem 'therubyracer'

4) 在 Gemfile & Run Bundle install 中取消注释 gem therubyracer

gem 'therubyracer'

【讨论】:

    【解决方案3】:

    此错误与 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 会再次下载一个出错的脚本。

    【讨论】:

      【解决方案4】:

      做:gem install rmagick -v '2.13.2'

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

      【讨论】:

        【解决方案5】:

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

        "which" 如果您安装了 DevKit 或 RailsInstaller,则应该安装。但是,我也遇到了这个问题(我也安装了许多版本的 python 并且可以正常工作),并且刚刚发现我在DevKit... 下的which 命令(以及 RailsInstaller 下的那个...)实际上并不是工作。

        接近等效的窗口是“where”。所以你应该运行“WHERE which”来找出你的系统上是否/在哪里有“which”命令。

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

        (我已将问题发布给 msysGit 人员,以了解他们对非执行“which”命令的看法。)

        【讨论】:

          【解决方案6】:

          试试这个:

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

          在我运行上述命令之前,这个错误很痛苦:)

          【讨论】:

          • 是的,我在 Windows 7 HP 64bit 上设置环境 :)
          • 你给我省了很多麻烦。赞一个。
          • 我必须将版本号更改为 3.16.14.3 才能正常工作。希望它可以帮助某人。
          • 感谢 Periback。到了一半......(我现在抱怨没有安装系统 V8 !!)。 IMO 令人震惊的是,这些东西在世界上最流行的操作系统上无法正常运行。
          • 这为我节省了数小时的故障排除时间——我什至想过重新安装 Ruby,但效果很好:)。
          【解决方案7】:

          按照以下步骤操作:

          1. 从这里获取合适的 Python http://python.org/download/
          2. 使用此命令设置路径SET PATH=&lt;ruby directory&gt;;&lt;python directory&gt;(例如SET PATH=C:\Ruby192\bin;C:\Python27

          现在安装你想要的 gem

          gem install libv8
          

          here得到这个解决方案。

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

          gem install libv8 --version 3.11.8.0 
          

          【讨论】:

          • 安装 3.11.8.0 成功,但 gem install libv8 (有或没有 --version 3.11.8.17) 没有:(
          【解决方案8】:

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

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

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

          也许尝试将python 别名为python2

          【讨论】:

          • 不起作用,我也尝试删除 setup_python!一起发挥作用。主要问题在于 windows 中没有对应的 which python 命令。
          • ruby devkit 有“which”,可能无论如何你都会在构建 libv8 的道路上使用它。但是这个安装程序在 Windows 上安装非常令人沮丧,并且可能由于其他原因进一步出错。
          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2016-11-04
          • 1970-01-01
          • 1970-01-01
          • 2023-04-01
          • 2013-09-09
          • 2015-07-01
          相关资源
          最近更新 更多