How to install Capybara on Linux


Using the Capybara on Linux, you need to install some dependencies.

You may get some errors like these:

Installing capybara-webkit (0.12.1) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

/home/franzejr/.rvm/rubies/ruby-1.9.2-p320/bin/ruby extconf.rb

Gem files will remain installed in /home/franzejr/.rvm/gems/ruby-1.9.2-p320@indica/gems/capybara-webkit-0.12.1 for inspection.
Results logged to /home/franzejr/.rvm/gems/ruby-1.9.2-p320@indica/gems/capybara-webkit-0.12.1/./gem_make.out
An error occured while installing capybara-webkit (0.12.1), and Bundler cannot continue.
Make sure that `gem install capybara-webkit -v ‘0.12.1’` succeeds before bundling.


`ensure_application_exists!’: Xvfb not found on your system (Headless::Exception)

group :test,:development do
     gem 'capybara'
     gem 'capybara-webkit'

Firstly you need to use the capybara-webkit and install QT dependencies in your OS.


sudo apt-get install libqt4-dev libqtwebkit-dev

Ubuntu 10.04 LTS

sudo apt-get install libqt4-dev

Debian Stable

sudo apt-get install libqt4-dev


yum install qt-webkit-devel

Fedora 16

yum install qtwebkit-devel

If you are using a recent version of Fedora, the qmake executable is now called qmake-qt4. This will cause the gem installation to fail. So you need to add an environment variable your profile or the system profile.

export QMAKE=/usr/bin/qmake-qt4

Gentoo Linux

emerge x11-libs/qt-webkit

About QT installation you may check here.

You will need to install  xvfb and also use Headless gem. Headless is the Ruby interface for Xvfb. It allows you to create a headless display straight from Ruby code, hiding some low-level action. It can also capture images and video from the virtual framebuffer.



2 thoughts on “How to install Capybara on Linux

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s