gem install libv8 --version '3.11.8.17' on ruby (windows)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16514758/
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
gem install libv8 --version '3.11.8.17' on ruby (windows)
提问by user2318042
The problem is as following.
问题如下。
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
Then I check the code as following.
然后我检查代码如下。
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
I tried to install the Linux command line to windows so that the 'ln -fs' should be working.But the problem still can not be solved.
我尝试将 Linux 命令行安装到 Windows,以便 'ln -fs' 应该可以工作。但问题仍然无法解决。
回答by sergioviniciuss
Try this:
尝试这个:
gem install libv8 -v '3.11.8.17' -- --with-system-v8
This error was a pain untill I run the above command :)
这个错误很痛苦,直到我运行上面的命令:)
回答by Vieenay Siingh
Try with https://github.com/eakmotion/therubyracer_for_windows. I had solved same problem on my windows machine using this solution.
尝试使用https://github.com/eakmotion/therubyracer_for_windows。我使用这个解决方案在我的 Windows 机器上解决了同样的问题。
回答by rony36
Follow these steps:
按着这些次序:
- Get suitable Python from here http://python.org/download/
- Set path with this command
SET PATH=<ruby directory>;<python directory>(e.g.SET PATH=C:\Ruby192\bin;C:\Python27)
- 从这里获取合适的 Python http://python.org/download/
- 使用此命令设置路径
SET PATH=<ruby directory>;<python directory>(例如SET PATH=C:\Ruby192\bin;C:\Python27)
And now install your desire gem
现在安装你想要的 gem
gem install libv8
Got this solution from here.
从这里得到这个解决方案。
I wonder if you are getting this error for version. Try this:
我想知道您是否收到此版本错误。尝试这个:
gem install libv8 --version 3.11.8.0
回答by aenw
Be sure that you can actually run the "which" command on your system. It's not native to Windows.
确保您实际上可以which在您的系统上运行“ ”命令。它不是 Windows 原生的。
"which" should be installed if you installed DevKit or RailsInstaller. However, I am running into this problem too (I also have a number of versions of python installed and working), and just discovered that my whichcommand under DevKit...(and the one under RailsInstaller...) is not actually working.
which如果您安装了 DevKit 或 RailsInstaller,则应安装“ ”。但是,我也遇到了这个问题(我也安装了许多版本的 python 并且正在运行),并且刚刚发现我的which命令DevKit...(以及 RailsInstaller 下的命令...)实际上不起作用。
The windows near equivalent is "where". So you should run "WHERE which" to find out if/where you have the "which" command on your system.
接近等效的窗口是“ where”。所以你应该运行“ WHERE which”来找出你的系统上是否/哪里有“which”命令。
That doesn't make 'therubyracer' work, or issues with libv8 go away, but it is part of the puzzle.
这不会使 'therubyracer' 工作,或者 libv8 的问题消失,但它是难题的一部分。
(I've posted the problem to the msysGit folks to see what they say about the non-executing 'which' command.)
(我已将问题发布给 msysGit 人员,以了解他们对非执行的“which”命令的看法。)
回答by abcd_win
do: gem install rmagick -v '2.13.2'
做: gem install rmagick -v '2.13.2'
and then do: gem install libv8 -v 3.11.8.17 -- --with-system-v8
然后做: gem install libv8 -v 3.11.8.17 -- --with-system-v8
回答by badbob
This error is about a libv8-3.11.8.17\ext\libv8\builder.rb script. On line 60 we can see this code:
此错误与 libv8-3.11.8.17\ext\libv8\builder.rb 脚本有关。在第 60 行,我们可以看到这段代码:
`python -c 'import platform; print(platform.python_version())'`.chomp
This is a wrong python command syntax in Windows. You should use a double quotes, like this:
这是 Windows 中错误的 python 命令语法。您应该使用双引号,如下所示:
`python -c "import platform; print(platform.python_version())"`.chomp
After fixing this script, you should run gem install with "-l" (use local only) key. If you don't, gem will download a script with an error again.
修复此脚本后,您应该使用“-l”(仅使用本地)键运行 gem install。如果不这样做,gem 将再次下载一个有错误的脚本。
回答by WiredIn
These are the following steps I have to take to get therubyracer to work on windows:
这些是我必须采取以下步骤才能让 therubyracer 在 Windows 上工作:
1) Install Python 2.7
1) 安装 Python 2.7
2) Go here here https://github.com/eakmotion/therubyracer_for_windowsand follow instructions
2) 到这里https://github.com/eakmotion/therubyracer_for_windows并按照说明操作
3) comment therubyracer gem in the Gemfile & Run Bundle install
3) 在 Gemfile & Run Bundle 安装中评论 therubyracer gem
#gem 'therubyracer'
4) Uncomment gem therubyracer in the Gemfile & Run Bundle install
4) 在 Gemfile & Run Bundle 安装中取消注释 gem therubyracer
gem 'therubyracer'
回答by Rots
I could be reading this wrong, but I think the problem is this line:
我可能读错了,但我认为问题在于这一行:
unless system 'which python2 2>&1 > /dev/null'
It's looking for python2when in fact the command for python is simply python.
它正在寻找python2实际上 python 的命令只是python.
Perhaps try aliasing pythonto python2.
也许尝试别名python为python2.

