Skip to content
This repository

capybara-webkit depends on a WebKit implementation from Qt (version >= 4.8), a cross-platform development toolkit. You'll need to download the Qt libraries to build and install the gem.

If you get an error when building, along the lines of fatal error: QObject: No such file or directory, you might be attempting the build against Qt3, or an earlier version of Qt4. Make sure that the qmake in your PATH links to Qt4.8.

which qmake # to see where it links
rm `which qmake` # IF it is linking to an old version 

OS X Mavericks 10.9 and Mountain Lion 10.8

QT Official Distribution

Go to the QT Downloads Page and download Qt libraries 4.8.4 for Mac (185 MB) and debug libraries (480 MB)

Open the dmg files and install.

Note: if using the official packages and the Xcode compiler, ensure that the command line tools are installed as well. Otherwise compiling will result in precompiled header errors, and the QT_VERSION_CHECK macro will not be found.

Homebrew

Install Qt via homebrew. Grab latest Qt Formula (newer than this commit: https://github.com/mxcl/homebrew/commit/2547ffd) Regular procedure is, first update the formulas, then try installing the built binary with:

brew update
brew install qt

If that doesn't work, try building it from source (which can take more than an hour):

brew install qt --build-from-source

Mountain Lion and newer version of OS X doesn't include X11, so you need to install it from http://xquartz.macosforge.org/landing/

OS X Lion 10.7

Homebrew

Install Qt via homebrew. First update the formulas, then try installing the built binary with:

brew update
brew install qt

If that doesn't work, try building it from source (which can take more than an hour):

brew install qt --build-from-source

Macports

Install Qt via macports.

sudo port install qt4-mac-devel

It took over three hours on i5 2.3 GHz with 8GB RAM, because it's compiling the Qt libraries.

As 10-Feb-2014, Macports (2.1.1) has temporarily replaced qt4-mac-devel with qt4-mac. Compilation was only ~5m on MacOS 10.8.5, Core 2 Duo 2.4 GHz (~2009) and 4GB RAM; not sure what the above contributor was experiencing.

sudo port install qt4-mac # => qt4-mac-4.8.5_1, compiling in ~5m

OS X < 10.7

The 4.8.0 release was bundled for OS X Lion only (see: https://bugreports.qt.nokia.com/browse/QTBUG-23157). Using the 4.8.0 release will result in errors like:

dyld: Symbol not found: _kCFWebServicesProviderDefaultDisplayNameKey
Referenced from: /Library/Frameworks/QtWebKit.framework/Versions/4/QtWebKit
Expected in: /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation

Try the 4.7.0 release until this is remedied.

An updated homebrew formula for qt will now install a snow-leopard compatible 4.8.1 release. 'brew install qt' now works on OS X 10.6

Debian testing, unstable, stable (wheezy) / Ubuntu

sudo apt-get install libqtwebkit-dev

before that if you haven't response for ´which qmake´, you must create a symbolic link for qmake-qt4 like ´ln -s qmake-qt4 qmake´

Ubuntu 10.04 LTS

sudo apt-get install libqt4-dev

Note that the version of Qt distributed with Ubuntu 10.04 is not compatible with capybara-webkit >= 0.14. But, you can compile Qt from source following this instructions.

Debian oldstable (squeeze)

Debian squeeze only has qt 4.6. Either you need to:

  • Update to Debian stable (wheezy)—and then see above, or
  • Install qt 4.8 from source, or
  • Revert to capybara-webkit 0.12 and then do
sudo apt-get install libqt4-dev

Fedora

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 dev-qt/qtwebkit

Arch Linux

pacman -S qt qtwebkit

openSUSE 11.4

sudo zypper in libqt4-devel libQtWebKit-devel

CentOS 6.2

rpm -i http://dl.atrpms.net/el6-x86_64/atrpms/stable/atrpms-repo-6-6.el6.x86_64.rpm 
yum install --enablerepo=atrpms-testing qt47-webkit-devel
export QMAKE=/usr/bin/qmake-qt47

CentOS 6.3

You cannot use qt47, it will conflict with the qt version that comes with 6.3. To be able to compile I had to add /usr/lib64/qt4/bin/ to my $PATH variable.

CentOS 6.3 + qt 4.8.5 + Ruby 2.0.0-p247 +capybara-webkit 1.0.0

You need qt 4.8.x at least with Ruby 2.0.x (Might be wrong, can't remember where I got it from).

After doing yum install [necessary_package], (qt48 is not available here so you have to compile.Word of caution: It takes around 6+ hours, please see this comment.)

wget http://download.qt-project.org/official_releases/qt/4.8/4.8.5/qt-everywhere-opensource-src-4.8.5.tar.gz
tar xzvf qt-everywhere-opensource-src-4.8.5.tar.gz
cd qt-everywhere-opensource-src-4.8.5.tar.gz
./configure --embedded
gmake (caution:this will take a long time, if there's any error and you need to reconfigure, you can use 'gmake confclean')
gmake install

Qt 4.8.5 installed. Now gem install capybara-webkit should work. If it comes with Command 'qmake -spec linux-g++' not available that means capybara-webkit is looking for qmake at usr/bin/qmake, whereas the path of qmake is /usr/local/Trolltech/QtEmbedded-4.8.5/bin/qmake

Using $PATH, symlink or update alternative should help capybara-webkit to find qmake. This link shows how one can use update alternative.

CentOS 6.4

# Place this in a file in your /etc/yum.repos.d/ directory with a .repo extension

[epel-qt48]
name=Software Collection for Qt 4.8
baseurl=http://repos.fedorapeople.org/repos/sic/qt48/epel-$releasever/$basearch/
enabled=1
skip_if_unavailable=1
gpgcheck=0

[epel-qt48-source]
name=Software Collection for Qt 4.8 - Source
baseurl=http://repos.fedorapeople.org/repos/sic/qt48/epel-$releasever/SRPMS
enabled=0
skip_if_unavailable=1
gpgcheck=0
yum install qt48-qt-webkit-devel
ln -s /opt/rh/qt48/root/usr/include/QtCore/qconfig-64.h  /opt/rh/qt48/root/usr/include/QtCore/qconfig-x86_64.h
source /opt/rh/qt48/enable
export PATH=/opt/rh/qt48/root/usr/lib64/qt4/bin/${PATH:+:${PATH}}
gem install capybara-webkit -v "1.0.0"

CentOS 5.8 (and possibly below)

vim /etc/yum.repos.d/atrpms-testing.repo

Copy & paste the following into vim:

[atrpms-testing]
name=EL $releasever - $basearch - ATrpms
baseurl=http://dl.atrpms.net/el$releasever-$basearch/atrpms/testing
gpgkey=http://ATrpms.net/RPM-GPG-KEY.atrpms
gpgcheck=1
enabled=0

Save & close the file (:wq) and run the following:

rpm --import http://packages.atrpms.net/RPM-GPG-KEY.atrpms
yum --enablerepo=atrpms-testing install qt47-webkit-devel qt47-devel sqlite
vim /etc/profile.d/qt.sh
export PATH=$PATH:/usr/lib/qt47/bin
export QMAKE=/usr/lib/qt47/bin/qmake-qt47

And finally, to install capybara-webkit (since for some reason remote install fails):

gem fetch capybara-webkit
gem install capybara-webkit.*.gem
rm capybara-webkit.*.gem

(If it comes with an error regarding "cannot find linux-g++" then it needs a symlink.):

ln -s /usr/lib64/qt47/bin/qmake /usr/lib/qt47/bin/qmake (might need to create those empty directory to fake it)
ln -s /usr/lib64/qt47/bin/qmake-qt47 /usr/lib/qt47/bin/qmake-qt47 (might need to create those empty directory to fake it)

then "gem install capybara-webkit" should work.

FreeBSD

Install the webkit library port from /usr/ports/www/qt4-webkit.

Windows

You need a working Ruby installation that behaves well with a proper mingw32 compilation toolchain.

Download the latest Ruby version and DevKit from here, the compilation toolchain you need is Qt libraries v4.8.5 for Windows or higher, from here. You'll also need a code editor or IDE (eg, here).

Avoid installing in directory paths that have directory names with 'white space'. eg, C:\Ruby193 is good, whereas avoid C:\Program Files\Ruby193 because it has a 'whitespace' between Program and Files.

Step-by-step instructions.

1) Install Ruby and DevKit:

eg, C:\Ruby193 and C:\DevKit

2) Install Qt libraries v4.8.x for Windows ,

eg C:\Qt\4.8.5

3) Run the DevKit installation scripts following the very clear directions for this step available here

4) Update some system paths, eg if you install Ruby, DevKit and Qt in the directories shown above:

  From ‘Start’, right click ‘Computer’, click ‘Advanced System Settings’, [if prompted, allow systemadvancedproperties.exe to run], click ‘Advanced’ tab, click ‘Environment variables…’ button, select ‘Path’ under user variables, click ‘edit’, and enter the following: C:\Ruby193\bin; c:\qt\4.8.5\bin;c:\devkit;c:\devkit\bin

5) Perform the famous Frommel Workaround:

 Launch your favorite [code editor or IDE](http://rubyonrails.org/ecosystem) and do the following:

 a) open the qmake.conf of your platform (for me its C:\Qt\4.8.5\mkspecs\win32-g++)

 b) find the line beginning with QMAKE_IDC

 c) add the following line after the QMAKE_IDC line:

    QMAKE_RCC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}rcc$${EXE_SUFFIX}
    QMAKE_LFLAGS = -static-libgcc -static-libstdc++

 d) save file and close editor

7) Open a command line in a window

 Start > Run > Open cmd

8) Clone latest version of capybara-webkit from Github:

 $ git clone git://github.com/thoughtbot/capybara-webkit.git

9) Bundle/Install capybara-webkit version:

 $ cd ruby193\capybara-webkit

 $ bundle install

10) Access the full Msys/MinGW environment:

 $ cd devkit

 $ devkitvars.bat

(Running devkitvars at this step is crucial, even though you may have run it previously at step 4 above.)

11) Compile the capybara-webkit within same cmd session as (10), run devkitvars again if you closed the cmd session before performing the following command:

 $ cd ruby193\capybara-webkit

 $ bundle exec rake build

12) Install the capybara-webkit gem:

 $ cd pkg && gem install capybara-webkit-1.0.0.gem

13) Smoke if you've got 'em

Discuss further on the capybara-webkit google group here

Something went wrong with that request. Please try again.