问题
I am a newbie. I am trying to build capybara-webkit (0.8.0) with native extensions on window 7. I already installed (path set):RubyMine, Ruby SDK and Gems, Rails, DevKit, Qt, gmake, g++. But I still got the following error msg. Any help is greatly appreciated.
$ gem install capybara-webkit -v '0.8.0' Temporarily enhancing PATH to include DevKit... Building native extensions. This could take a while... ERROR: Error installing capybara-webkit: ERROR: Failed to build gem native extension.
c:/Ruby193/bin/ruby.exe extconf.rb
c:\Qt\4.8.2\bin\qmake.EXE c:\make\gmake.EXE cd src/ && c:/Qt/4.8.2/bin/qmake.exe c:/Ruby193/lib/ruby/gems/1.9.1/gems/capybara-webkit-0.8.0/src/webkit_server.pro -spec c:/Qt/4.8.2/mkspecs/macx-g++ -o Makef\ile.webkit_server c:\make\gmake.EXE cd src/ && gmake -f Makefile.webkit_server gmake[1]: Entering directory `c:/Ruby193/lib/ruby/gems/1.9.1/gems/capybara-webkit-0.8.0/src' g++ -c -pipe -g -Wall -W -DQT_WEBKIT_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -Ic:/Qt/4.8.2/mkspecs/macx-g++ -I. -Ic:/Qt/4.8.2/include/QtCore -Ic:/Qt/4.8.2/include/QtNetwork -Ic:/Qt/4.8.2/include/QtGui -Ic:/Qt/4.8.2/include/QtWebKit -Ic:/Qt/4.8.2/include -I. -o RequestedUrl.o RequestedUrl.cpp process_begin: CreateProcess((null), g++ -c -pipe -g -Wall -W -DQT_WEBKIT_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -Ic:/Qt/4.8.2/mkspecs/macx-g++ -I. -Ic:/Qt/4.8.2/include/QtCore -Ic:/Qt/4.8.2/include/QtNetwork -Ic:/Qt/4.8.2/include/QtGui -Ic:/Qt/4.8.2/include/QtWebKit -Ic:/Qt/4.8.2/include -I. -o RequestedUrl.o Req uestedUrl.cpp, ...) failed. make (e=2): The system cannot find the file specified.
gmake[1]: * [RequestedUrl.o] Error 2
gmake[1]: Leaving directory c:/Ruby193/lib/ruby/gems/1.9.1/gems/capybara-webkit-0.8.0/src'
c:/Ruby193/lib/ruby/1.9.1/fileutils.rb:1515:in
stat': No such file or directory
- src/webkit_server (Errno::ENOENT)
from c:/Ruby193/lib/ruby/1.9.1/fileutils.rb:1515:in block in fu_each_src_dest'
from c:/Ruby193/lib/ruby/1.9.1/fileutils.rb:1529:in
fu_each_src_dest0'
from c:/Ruby193/lib/ruby/1.9.1/fileutils.rb:1513:in fu_each_src_dest'
from c:/Ruby193/lib/ruby/1.9.1/fileutils.rb:395:in
cp'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/capybara-webkit-0.8.0/lib/capybara_webkit_builder.rb:33:in build'
from c:/Ruby193/lib/ruby/gems/1.9.1/gems/capybara-webkit-0.8.0/lib/capybara_webkit_builder.rb:39:in
build_all'
from extconf.rb:2:in `'
Gem files will remain installed in c:/Ruby193/lib/ruby/gems/1.9.1/gems/capybara-webkit-0.8.0 for inspection. Results logged to c:/Ruby193/lib/ruby/gems/1.9.1/gems/capybara-webkit-0.8.0/./gem_make.out
回答1:
I was getting similar errors to this, as well as errors such as:
g++.exe: unrecognized option '-headerpad_max_install_names'
make[1]: Leaving directory /ruby/gems/shared/gems/capybara-webkit-0.12.1/src'
Errno::ENOENT: No such file or directory - C:/JRuby/lib/ruby/gems/shared/gems/capybara-webkit-0.12.1/src/webkit_server
LoadError: no such file to load
No such file or directory - C:/Ruby/capybara-webkit-0.12.1/src/webkit_server
Basically the answer to all these errors is to do with the version of capybara-webkit that you install on Windows depending on exactly the right versions of QT, and the right version of the g++ compiler included in mingw toolset. The right versions have to be installed and the correct bin directories added to your windows path.
Plus, there are issues with RbConfig::CONFIG['host_os']
which on windows 8 returns "mswin32" and not "mingw32". Therefore you have to fix capybara_webkit_builder.rb and spec_helper.rb to the following: /mingw32|mswin32/
. If you don't do this then you will run macx-g++ which won't work on windows. You have to run win32-g++ on windows.
If you're using JRuby, then the RUBY_PLATFORM
is set to "java". Therefore you have to change corresponding capybara_webkit_builder.rb and connection.rb to /mingw32|java/
. If you don't do this, then the binary will compile (but with a bug in connection) but the compiler will crash out with the can't find the webkit-server error.
You have to follow the install script at https://github.com/thoughtbot/capybara-webkit/wiki/Installing-Qt-and-compiling-capybara-webkit
At the final instruction on windows, you have to "cd" to the gem directory and then run
bundle exec gem install capybara-webkit-0.12.1.gem
or whichever version you have built.
So, the answers are get all the right versions of each dependency, fix the bugs, ensure the windows path variable points to the right versions of g++ compilers (don't forget to restart cmd after you've changed the path variable) and then ensure you're in the right directory when you run commands.
来源:https://stackoverflow.com/questions/11480048/capybara-webkit-0-8-0-failed-to-build-on-window-7