Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capybara Webkit Capybara::Webkit::ConnectionError failed to start

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

like image 367
roinir Avatar asked Nov 26 '14 12:11

roinir


2 Answers

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.

like image 73
Patru Avatar answered Nov 10 '22 18:11

Patru


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.

like image 44
David Hempy Avatar answered Nov 10 '22 17:11

David Hempy