Skip to content


Compiling on Windows #188

wants to merge 12 commits into from

7 participants


It now compiles on Windows using its QT SDK:
There are 7 failing specs due to ImageMagick on Windows, and I'm looking into solving them.

@jferris jferris commented on an outdated diff
((11 lines not shown))
rack (1.3.2)
rack-test (0.6.1)
rack (>= 1.0)
- rake (0.9.2)
@jferris thoughtbot, inc. member
jferris added a note

Why did you downgrade rake?

Oh well, I had the Rake::DSL not found problem on my machine with 0.9.2.
I then forgot to fix that before commit, now I restored 0.9.2 and merged with master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@morenocarullo morenocarullo Merge remote-tracking branch 'upstream/master'
@mike-burns mike-burns commented on an outdated diff
((6 lines not shown))
+ def kill_process(pid)
+ if RUBY_PLATFORM =~ /mingw32/
+ Process.kill(9, pid)
@mike-burns thoughtbot, inc. member

Just for our edification, why 9 for mingw32 instead of the 2 (INT) we use elsewhere?

see comment below

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

If I try Process.kill(2, pid) on Windows (Vista) it says:

Invalid argument (Errno::EINVAL)

just as the string version of the signal.

thoughtbot, inc. member

It'd be nice if we could get some input from another Windows user here.

Does this work? Do the tests pass?


The first commits had all green specs. With the additions of some specs, these 3 now fail:


1) Capybara::Driver::Webkit::Browser forking only shuts down the server from the main process
Failure/Error: pid = fork {}
fork() function is unimplemented on this machine
# ./spec/browser_spec.rb:87:in fork'
# ./spec/browser_spec.rb:87:in
block (3 levels) in '

2) Capybara::Driver::Webkit::Browser#set_proxy uses the proxies' response
Failure/Error: @proxy_requests.size.should == 2
expected: 2
got: 1 (using ==)
# ./spec/browser_spec.rb:138:in `block (3 levels) in '

3) Capybara::Driver::Webkit::Browser#set_proxy is possible to disable proxy again
Failure/Error: @proxy_requests.size.should == 2
expected: 2
got: 1 (using ==)
# ./spec/browser_spec.rb:138:in `block (3 levels) in '

for the first one, it is impossibile to get it work on Windows since it doesn't have fork. For the other two, I can hack on and see what's going wrong.

I think that if the Windows compilation compatibility gets into mainstream, the chance to have feedback from other Windows users will be higher.


An update on the set_proxy specs. It appears to be a race condition, in fact if I add a sleep(5) after line 140, all specs pass.

thoughtbot, inc. member

I'd like to get his merged if possible. In order to do so I'll need a couple of things to happen. The forking test should be disabled using rspec metadata via checking the host os instead of wrapping it with the conditional, that way any additional tests that will need to be disabled can be. Also the race condition will need a better solution than sleep(5) :D.


Ok for rspec metadata I'll check how that works (I am not a rspec expert, using Test-unit most of the times).

For the race condition: I think the problem is not windows-related, and is certainly a test-related issue and not production-code-related issue. I was not able to really 'solve' the problem without reinventing the way the test is layed out.


Moving this discussion from Issue #148 where it was somewhat off-topic.

I could not compile with the latest QT 4.8.0 libraries (also ruby 1.9.3p0 (2011-10-30) [i386-mingw32], and the latest DevKit 4.5.2-20111229-1559). I backed down Qt to version 4.7.4 per Moreno's instructions and it compiled with no problems.

For your info, the 4.8.0 error was as follows:

WebPage.cpp: In member function 'void WebPage::ignoreSslErrors(QNetworkReply*, const QList&)':
WebPage.cpp:199: error: no matching function for call to 'QNetworkReply::ignoreSslErrors(const QList&)'
../../../bin/Qt/4.8.0/include/QtNetwork/../../src/network/access/qnetworkreply.h:145: note: candidates are: virtual void QNetworkReply::ignoreSslErrors()


Thanks @mtjhax for your report. I didn't tried QT 4.8.0, and in fact I don't know if this is really Windows-specific. Otherwise we could update capybara-webkit's wiki to suggest the 4.7.x version for now.


Ok, now we can skip any kind of test with the :skip_on_windows => true metadata (@halogenandtoast, did you meant something different?).

The race condition I was noticing on Windows with Ruby 1.9.2 is no longer there with 1.9.3.p0: tried many many times -- beforewards it appeared almost every run.

thoughtbot, inc. member

@morenocarullo Yeah that's what I meant with the meta data. If possible I'd like a few other windows users to chime in on this and confirm it compiles and passes the tests.


Just confirming, I was able to compile on Windows with Qt 4.7.4 (and actually, capybara-webkit's wiki already says to use Qt 4.7.x -- I missed that when I was rushing headlong to try this out). One problem though -- I can compile but I can't seem to get the gem to install. We could cycle on what stupid thing I am doing, but it might be faster if someone could post a brief set of compile and install steps (assuming Qt is already installed).


Here is some feedback.
I have Windows XP, ruby 1.9.2, rails 3.1.3. I succeeded installing capybara-webkit and building my first test requiring javascript execution, this way :

  • in my gemfile: gem 'capybara-webkit', :git => 'git://' (on January, the 22th)
  • installing QT 4.7.4
  • As QT installation did not like (warning issued) the migwn version available in my RailsInstaller, I installed QT SDK and used included migwn.
  • With the QT default installation paths, I had to add to my PATH : C:\Qt\4.7.4\bin and C:\QtSDK\mingw\bin

Hope it helps.


Oh perfect @elestrade.

In my machine I use Windows Vista Professional, Ruby 1.9.3-p0 from RubyInstaller and QT 4.7.4. QT bin path is in PATH. Using the devkit from RubyInstaller the only thing to do manually before rake install is to launch the devkitvars.bat from devkit's root path.


@morenocarullo: Thanks for creating your fork, I was able to get capybara-webkit installed properly using it.

For any windows users who happen upon this and keep getting an error like:

mingw32-make.exe: Interrupt/Exception caught (code = 0xc0000005, addr = 0x41f96e)

Check your path for anything being used in the build (ruby, msysgit, qt, mingw) and be sure NONE of them are installed in directories that have any parentheses in the directory. For whatever reason, that causes mingw32-make.exe to fail with that super helpful error message.


@morenocarullo: Perhaps I spoke too soon. I'm new to capybara-webkit, so I have no idea if this is something specific to your fork or the gem in general... anyway, switching things over to run using the :webkit driver (following the steps here), it hangs after the first test in my suite. The following lines are in the console in RubyMine:

QSslSocket: cannot call unresolved function SSLv3_client_method
QSslSocket: cannot call unresolved function SSL_CTX_new
QSslSocket: cannot call unresolved function SSL_library_init
QSslSocket: cannot call unresolved function ERR_get_error

If I switch back to the :selenium driver all the tests run properly, so it seems reasonably likely it's something with the :webkit driver setup.


@mewdriller, which version of QT did you install? Did you add the QT bin directory to system PATH? And, moreover, which Windows version and arch (32/64 bit) are you using?


@morenocarullo, I have Qt 4.7.4 installed and on my PATH. I'm on Windows 7 64bit.


@mewdriller, I'm sorry but I don't have a 64bit Windows 7 to try the thing. However, maybe you can create here on github a minimal app & test project that hangs on your machine so we can see if it is something capybara-webkit related or windows7@64-bit specific.

thoughtbot, inc. member

I'm going to close this pull request, since it's been a long time since the code has been updated and the build script has changed significantly. If there are general questions or discussion of compiler issues, please raise them on the mailing list:!forum/capybara-webkit

@jferris jferris closed this

Dear @jferris, the problem is not about compilation. As you can see in the code, the problem is also related to os-specific functionalities.

I'm a little disappointed, and maybe all the other users working on Windows.

thoughtbot, inc. member

@morenocarullo Based on the comments, it seems like it's still not functioning on Windows with this pull request. Is that not the case?

@jferris jferris reopened this

@jferris, as you can see, the thing is functioning correctly at least on Windows 32bit.
The comments are on this pull request and on #148.


"I'm a little disappointed, and maybe all the other users working on Windows."

If I understand well, we have three positive feedbacks (morenocarullo, mtjhax and I) and one negative (mewdriller). The problem of mewdriller is suspected to be linked to Windows 64bit.

Even if it is not perfect, it seems better that the situation of the master branch which can not be used at all on Windows (unless I missed a point?).

[all this beeing an humble remark as I am new to capyraba-webkit and also new to github]


yes, exactly @elestrade. If needed, I can sync my branch with capybara-webkit's master, with little effort.

thoughtbot, inc. member

@morenocarullo I've merged this in. I squashed your commits and removed some of the whitespace changed you made in order to make the diff more clear as to what was happening. I've also added a note about window support in the README stating that only 32bit Windows is currently supported.

thoughtbot, inc. member

@morenocarullo, @elestrade, @mtjhax: Could you let me know if master works correctly for you so when I release the next version of the gem I can have some additional confidence in the Windows changes - especially since I needed to alter some of the binary checking to match what we're currently doing.


See #300 for a small fix, thanks!
In the while I added an entry to the wiki for proper installation of QT.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 6, 2011
  1. @morenocarullo
Commits on Oct 7, 2011
  1. @morenocarullo
  2. @morenocarullo
Commits on Oct 10, 2011
  1. @morenocarullo
Commits on Oct 17, 2011
  1. @morenocarullo

    Merge remote-tracking branch 'upstream/master'

    morenocarullo committed
Commits on Oct 26, 2011
  1. @morenocarullo
Commits on Nov 2, 2011
  1. @morenocarullo
Commits on Nov 14, 2011
  1. @morenocarullo
Commits on Nov 17, 2011
  1. @morenocarullo
Commits on Jan 19, 2012
  1. @morenocarullo
Commits on Jan 20, 2012
  1. @morenocarullo
  2. @morenocarullo
Showing with 69 additions and 26 deletions.
  1. +3 −1 .gitignore
  2. +3 −0 Gemfile.lock
  3. +19 −10 lib/capybara/driver/webkit/browser.rb
  4. +33 −10 lib/capybara_webkit_builder.rb
  5. +3 −2 spec/browser_spec.rb
  6. +8 −3 spec/spec_helper.rb
4 .gitignore
@@ -1,5 +1,5 @@
@@ -12,6 +12,8 @@ moc_*.cpp
3 Gemfile.lock
@@ -21,11 +21,13 @@ GEM
ffi (~> 1.0.6)
diff-lcs (1.1.2)
ffi (1.0.9)
+ ffi (1.0.9-x86-mingw32)
json_pure (1.6.1)
mime-types (1.16)
mini_magick (3.2.1)
subexec (~> 0.0.4)
nokogiri (1.5.0)
+ nokogiri (1.5.0-x86-mingw32)
rack (1.3.2)
rack-test (0.6.1)
rack (>= 1.0)
@@ -54,6 +56,7 @@ GEM
+ x86-mingw32
appraisal (~> 0.4.0)
29 lib/capybara/driver/webkit/browser.rb
@@ -2,6 +2,7 @@
require 'thread'
require 'capybara/util/timeout'
require 'json'
+require 'rbconfig'
class Capybara::Driver::Webkit
class Browser
@@ -9,9 +10,9 @@ class Browser
def initialize(options = {})
@socket_class = options[:socket_class] || TCPSocket
- @stdout = options.has_key?(:stdout) ?
- options[:stdout] :
- $stdout
+ @stdout = options.has_key?(:stdout) ?
+ options[:stdout] :
+ $stdout
@ignore_ssl_errors = options[:ignore_ssl_errors]
@@ -113,7 +114,7 @@ def clear_cookies
def get_cookies
- command("GetCookies"){ |line| line.strip }.select{ |line| !line.empty? }
+ command("GetCookies") { |line| line.strip }.select { |line| !line.empty? }
def set_proxy(options = {})
@@ -147,11 +148,19 @@ def register_shutdown_hook
@owner_pid =
at_exit do
if == @owner_pid
- Process.kill("INT", @pid)
+ kill_process(@pid)
+ def kill_process(pid)
+ if RbConfig::CONFIG['host_os'] =~ /mingw32/
+ Process.kill(9, pid)
+ else
+ Process.kill("INT", pid)
+ end
+ end
def server_pipe_and_pid(server_path)
cmdline = [server_path]
cmdline << "--ignore-ssl-errors" if @ignore_ssl_errors
@@ -207,7 +216,7 @@ def check
if result.nil?
raise WebkitNoResponseError, "No response received from the server."
- elsif result != 'ok'
+ elsif result != 'ok'
raise WebkitInvalidResponseError, read_response
@@ -223,10 +232,10 @@ def read_response
def default_proxy_options
- :host => "localhost",
- :port => "0",
- :user => "",
- :pass => ""
+ :host => "localhost",
+ :port => "0",
+ :user => "",
+ :pass => ""
43 lib/capybara_webkit_builder.rb
@@ -4,21 +4,35 @@
module CapybaraWebkitBuilder
extend self
+ def has_binary?(binary)
+ case RbConfig::CONFIG['host_os']
+ when /mingw32/
+ system("#{binary} --version")
+ else
+ system("which #{make}")
+ end
+ end
def make_bin
make_binaries = ['gmake', 'make']
- make_binaries.detect { |make| system("which #{make}") }
+ make_binaries.detect { |make| has_binary?(make) }
- def makefile
+ def qmake_bin
qmake_binaries = ['qmake', 'qmake-qt4']
- qmake = qmake_binaries.detect { |qmake| system("which #{qmake}") }
+ qmake_binaries.detect { |qmake| has_binary?(qmake) }
+ end
+ def makefile
case RbConfig::CONFIG['host_os']
when /linux/
- system("#{qmake} -spec linux-g++")
+ system("#{qmake_bin} -spec linux-g++")
when /freebsd/
- system("#{qmake} -spec freebsd-g++")
+ system("#{qmake_bin} -spec freebsd-g++")
+ when /mingw32/
+ system("#{qmake_bin} -spec win32-g++")
- system("#{qmake} -spec macx-g++")
+ system("#{qmake_bin} -spec macx-g++")
@@ -26,16 +40,25 @@ def qmake
system("#{make_bin} qmake")
+ def path_to_binary
+ case RbConfig::CONFIG['host_os']
+ when /mingw32/
+ 'src/debug/webkit_server.exe'
+ else
+ 'src/webkit_server'
+ end
+ end
def build
system(make_bin) or return false
- FileUtils.mkdir("bin") unless"bin")
- FileUtils.cp("src/webkit_server", "bin", :preserve => true)
+ FileUtils.mkdir("bin") unless"bin")
+ FileUtils.cp(path_to_binary, "bin", :preserve => true)
def build_all
makefile &&
- qmake &&
- build
+ qmake &&
+ build
5 spec/browser_spec.rb
@@ -81,7 +81,8 @@
browser_ignore_ssl_err.visit "https://#{@host}:#{@port}/"
- describe "forking" do
+ describe "forking", :skip_on_windows => true do
it "only shuts down the server from the main process" do
pid = fork {}
@@ -95,7 +96,7 @@
@host = ''
@user = 'user'
@pass = 'secret'
- @url = ""
+ @url = ""
@server =, 0)
@port = @server.addr[1]
11 spec/spec_helper.rb
@@ -1,5 +1,6 @@
require 'rspec'
require 'rspec/autorun'
+require 'rbconfig'
PROJECT_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..')).freeze
@@ -10,12 +11,16 @@
spec_dir = nil
$:.detect do |dir|
if File.exists? File.join(dir, "capybara.rb")
- spec_dir = File.expand_path(File.join(dir,"..","spec"))
- $:.unshift( spec_dir )
+ spec_dir = File.expand_path(File.join(dir, "..", "spec"))
+ $:.unshift(spec_dir)
-require File.join(spec_dir,"spec_helper")
+RSpec.configure do |c|
+ c.filter_run_excluding :skip_on_windows => !(RbConfig::CONFIG['host_os'] =~ /mingw32/).nil?
+require File.join(spec_dir, "spec_helper")
require 'capybara/driver/webkit/browser'
$webkit_browser = => TCPSocket, :stdout => nil)
Something went wrong with that request. Please try again.