gem install libv8 --version '3.11.8.17' on

2019-01-08 06:42发布

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.

8条回答
来,给爷笑一个
2楼-- · 2019-01-08 07:05

do: gem install rmagick -v '2.13.2'

and then do: gem install libv8 -v 3.11.8.17 -- --with-system-v8

查看更多
Juvenile、少年°
3楼-- · 2019-01-08 07:08

Try with https://github.com/eakmotion/therubyracer_for_windows. I had solved same problem on my windows machine using this solution.

查看更多
SAY GOODBYE
4楼-- · 2019-01-08 07:16

Be sure that you can actually run the "which" command on your system. It's not native to 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 which command under DevKit... (and the one under RailsInstaller...) is not actually working.

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.

That doesn't make 'therubyracer' work, or issues with libv8 go away, but it is part of the puzzle.

(I've posted the problem to the msysGit folks to see what they say about the non-executing 'which' command.)

查看更多
爷的心禁止访问
5楼-- · 2019-01-08 07:19

Follow these steps:

  1. Get suitable Python from here http://python.org/download/
  2. Set path with this command SET PATH=<ruby directory>;<python directory> (e.g. SET PATH=C:\Ruby192\bin;C:\Python27)

And now install your desire 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 
查看更多
何必那么认真
6楼-- · 2019-01-08 07:21

This error is about a libv8-3.11.8.17\ext\libv8\builder.rb script. On line 60 we can see this code:

`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:

`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.

查看更多
Explosion°爆炸
7楼-- · 2019-01-08 07:23

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 python2 when in fact the command for python is simply python.

Perhaps try aliasing python to python2.

查看更多
登录 后发表回答