Capybara Webkit Capybara::Webkit::ConnectionError failed to start
Asked Answered
S

2

8

I'm using capybara webkit on Ubuntu (14.04 LTS) and I'm getting the following error when trying to use it:

Capybara::Webkit::ConnectionError: /srv/www/app/shared/bundle/ruby/2.1.0/gems/capybara-webkit-1.3.1/bin/webkit_server failed to start.
from /srv/www/app/shared/bundle/ruby/2.1.0/gems/capybara-webkit-1.3.1/lib/capybara/webkit/connection.rb:75:in `parse_port'
from /srv/www/app/shared/bundle/ruby/2.1.0/gems/capybara-webkit-1.3.1/lib/capybara/webkit/connection.rb:81:in `discover_port'
from /srv/www/app/shared/bundle/ruby/2.1.0/gems/capybara-webkit-1.3.1/lib/capybara/webkit/connection.rb:62:in `start_server'
from /srv/www/app/shared/bundle/ruby/2.1.0/gems/capybara-webkit-1.3.1/lib/capybara/webkit/connection.rb:25:in `initialize'
from /srv/www/app/shared/bundle/ruby/2.1.0/gems/capybara-webkit-1.3.1/lib/capybara/webkit/driver.rb:17:in `new'

I installed QT using:

sudo apt-get install libqt4-dev libqtwebkit-dev libqt5webkit5-dev

Using gem versions: capybara (2.4.4) and capybara-webkit (1.3.1)

The same program works fine on mac (qt installed using homebrew)

Thanks

Smog answered 26/11, 2014 at 12:16 Comment(0)
C
10

It has been a long time since this question was asked, but I had the same problem even though I used much more ancient versions of anything. It turned out that webkit needs to be able to connect to some X-Server and this is its reaction if it fails. I ended up installing xvfb and using

 xvfb-run --auto-servernum bundle exec rake test

(aliased of course) when running my tests. This is probably less than optimal, but it was good enough for me. Maybe this helps the next person who stumbles across this error.

Continuator answered 4/8, 2015 at 13:37 Comment(0)
T
4

I beat my head against this all morning. Turns out I had omitted this code from rails_helper.rb :

if ENV['HEADLESS']
  require 'headless'
  headless = Headless.new
  headless.start
  at_exit { headless.stop }
end

We use the HEADLESS environment variable to trigger this. Not sure if that's typical or a local convention. Regardless, I needed to add export HEADLESS=1 to .env to fire that off.

I also had to add gem 'headless', '~> 1.0.2' in Gemfile.

Titanate answered 24/2, 2015 at 21:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.