-
-
Notifications
You must be signed in to change notification settings - Fork 428
Installing Qt and compiling capybara webkit
If you don't see your system here and you get capybara-webkit to compile using Qt 5, please edit this page to share your knowledge with future users.
Please do not edit this page to recommend Qt 4!
Qt 4 is several years old and contains a version of WebKit with many serious defects. Support for Qt 4 will be dropped in any future feature releases and is not supported by the capybara-webkit team. If you add instructions to this page, please make sure your instructions build using Qt 5.
Thanks for contributing!
capybara-webkit depends on a WebKit implementation from Qt, a cross-platform development toolkit. You'll need to download the Qt libraries to build and install the gem. You should install at least version 5.0, as the 4.8 series is now fairly old and contains a number of bugs that have since been fixed.
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 an older version of Qt. Make sure that the qmake
in your PATH
links to the latest version of Qt you have installed. Uninstall the previous version if exists.
which qmake # to see where it links
rm `which qmake` # IF it is linking to an old version
- macOS Catalina 10.15
- macOS Mojave 10.14
- macOS High Sierra 10.13, macOS Sierra 10.12, El Capitan 10.11 and Yosemite 10.10
- OS X Mavericks 10.9 and Mountain Lion 10.8
- OS X Lion 10.7
- Debian & Ubuntu
- Fedora 24, 25
- Gentoo Linux
- Arch Linux
- openSUSE Tumbleweed
- openSUSE 13.2, openSUSE Leap 42.1
- CentOS 7
- CentOS 6.7
- CentOS 5.8 (and possibly below)
- Alpine Linux 3.4
- Solus 3.99
- FreeBSD
- Windows
The instructions for High Sierra (10.13) work for Catalina. Tested on a clean Catalina install with Xcode 11.1. Note that you need both the command line tools as well as the full Xcode installed. You will encounter several of the errors mentioned in the 10.13 install instruction, but the mitigations mentioned there work, so read them carefully.
Prerequisite: Xcode 10 (Tested with Xcode 10.3 and macOS 10.14.6)
Qt 5.5 is the last version of Qt that capybara-webkit will support. The Qt project has dropped the WebKit bindings from binary releases in 5.6. Download and install Qt from this link. Be sure to uninstall completely any previous Qt install attempts.
After installing Qt 5.5, open a terminal an add the Qt binaries to your path:
echo 'export PATH="$HOME/Qt5.5.0/5.5/clang_64/bin:$PATH"' >> ~/.bash_profile
Change the previous path to point to the folder where you installed Qt. Remember to restart your terminal after executing the previous command. Now test it:
which qmake
You should get something like /Users/your_user/Qt5.5.0/5.5/clang_64/bin/qmake
or whatever place you have installed Qt. If you don't get anything is because qmake is not in your path (verify the previous step).
Now, you need to find the file Qt5.5.0/5.5/clang_64/mkspecs/features/mac/default_pre.prf
and replace:
isEmpty($$list($$system("/usr/bin/xcrun -find xcrun 2>/dev/null")))
With:
isEmpty($$list($$system("/usr/bin/xcrun -find xcodebuild 2>/dev/null")))
Now, test xcode build:
xcodebuild -version
You should get something like "Xcode 10.3 Build version 10G8". If you get xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance
, fix it running:
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
Now try to install the gem again.
Prerequisite: Xcode (between 9.4 - 10.1). If you need to downgrade Xcode following a future release follow this link
Install with either Homebrew or macports
Qt 5.5 is the last version of Qt that capybara-webkit will support. The Qt project has dropped the WebKit bindings from binary releases in 5.6.
Make sure that you have Xcode installed. Under Xcode preferences locations, make sure there is a version set.
Qt 5.5 was removed from homebrew in this commit. The previous/parent commit was 9ba3d6e.
So, to be able to install Qt 5.5 with homebrew checkout the old commit first:
brew update
cd $( brew --prefix )/Homebrew/Library/Taps/homebrew/homebrew-core
git checkout 9ba3d6ef8891e5c15dbdc9333f857b13711d4e97 Formula/qt@5.5.rb
NOTE: If you got error fatal: reference is not a tree: 9ba3d6ef8891e5c15dbdc9333f857b13711d4e97
, use git fetch --unshallow
to complete git history.
NOTE: If you get Error: qt@5.5: unknown version :mountain_lion
, comment line #25 in Formula/qt@5.5.rb
Install Qt 5.5 with homebrew:
brew install qt@5.5
The Homebrew formula for qt@5.5 is keg only which means binaries like qmake
will not be symlinked into your
/usr/local/bin
directory and therefore will not be available for capybara-webkit
.
Then add to your shell configuration file:
echo 'export PATH="$(brew --prefix qt@5.5)/bin:$PATH"' >> ~/.zshrc
Alternate Solution (Not recommended)
This will break on brew upgrade
.
The solution is to force Homebrew to symlink those binaries into your /usr/local/bin
directory:
brew link --force qt@5.5
Restart your terminal.
After running this command you should get the following output:
$ which qmake
/usr/local/bin/qmake
If it doesn't work you can try to create link to the binary folder with ln -s command:
ln -s /usr/local/Cellar/qt@5.5/5.5.1_1/bin/qmake /usr/local/bin/qmake
If you don't want to modify your PATH
variable for some reason, then you can also set the qmake
path when running gem install capybara-webkit
:
QMAKE="$(brew --prefix qt@5.5)/bin/qmake" gem install capybara-webkit
NOTE: If you get error: Project ERROR: Xcode not set up properly. You may need to confirm the license agreement by running /usr/bin/xcodebuild.
run this command:
`sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer`
It can also be done when bundle updating:
QMAKE="$(brew --prefix qt@5.5)/bin/qmake" bundle update capybara-webkit
Install qt5 with macports:
sudo port install qt5 qt5-qtwebkit # It's not qt5-mac anymore.
(This seems to have installed qt5 qt5-qtwebkit @5.8.0_0
for me but it built without problem, so the above comment about Qt 5.5
being the last supported version does not appear to apply anymore. Maybe someone with better knowledge about Qt than me can clarify.)
The default location for qt5's qmake is /opt/local/libexec/qt5/bin/qmake
. You can symlink it to a place in your PATH
. Like:
sudo ln -s /opt/local/libexec/qt5/bin/qmake /usr/local/bin/qmake
If the qmake on path is different, you can indicate the correct one with QMAKE environment variable.
QMAKE=/opt/local/libexec/qt5/bin/qmake gem install capybara-webkit
It can also be done when bundle updating
QMAKE=/opt/local/libexec/qt5/bin/qmake bundle update capybara-webkit
Go to the QT website (general downloads site) and download the latest stable version of Qt.
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.
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 linking fails, ensure /usr/local/Frameworks
exists and that you can write to it, and run brew link qt
. If installation fails for some other reason, try building it from source (which can take more than an hour):
brew install qt --build-from-source
Mountain Lion and newer versions of OS X don't include X11, so it needs to be installed from http://xquartz.macosforge.org/landing/
capybara-webkit does work with mp4 videos on OSX 10.9 Mavericks, but not with Qt 4.8.6, only with Qt 5 (due to the updated Webkit implementation that ships with Qt 5). See this blog post, if interested in the details. Please note that some users have experienced hangs with Qt 5, while others have not. It might depend on your use case.
Qt 5 sadly requires the full Xcode to be installed (> 5 GB), as opposed to previous versions of Qt which didn't. NB: We warn against using tools that try to avoid installing the full Xcode by overwriting system files in /usr/bin, since that has caused problems for other users, forcing them to reinstall OSX.
When installing Qt 5, Qt 4.x should be uninstalled, to prevent interference. You can download the official Qt 5 dmg and install it that way, as previously explained. Once installed via the package, one simply needs to set the QMAKE environment variable and bundle. Or you can upgrade with Homebrew, in the following way:
brew uninstall qt
brew install qt5
ln -s /usr/local/Cellar/qt5/5.4.1/bin/qmake /usr/local/bin/qmake
The last line is to symlink qmake, so that qmake -v
will run and report: QMake version 3.0 Using Qt version 5.4.1 in /usr/local/Cellar/qt5/5.4.1/lib
. Your Qt 5 version might be more recent than 5.4.1. Also run brew doctor
afterwards, to make sure everything is fine.
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
Install Qt via macports.
sudo port install qt5-mac
sudo apt-get update
sudo apt-get install g++ qt5-default libqt5webkit5-dev gstreamer1.0-plugins-base gstreamer1.0-tools gstreamer1.0-x
If this command does not work then run following command:
sudo apt-get install qt-sdk
QtWebKit now requires gstreamer; without gstreamer you may get EOFError
s on visit
.
To install using qt5:
[sudo] dnf install qt5-qtwebkit-devel
export QMAKE=/usr/bin/qmake-qt5
emerge dev-qt/qtwebkit
Having both qt4 and qt5 on your system at once might cause trouble when compiling capybara-webkit, due to the qmake linking to qt4, when the package dev-qt/qtwebkit
was installed for qt5. To resolve this issue, specify the qt/qmake version manually:
export QT_SELECT=qt5
bundle install OR gem install capybara-webkit
sudo pacman -S qt5-webkit
This pulls all the other dependencies, such as qt5-base
and openssl-1.0
, and some xcb
-related packages.
zypper install libQt5WebKitWidgets-devel
QMAKE=/usr/bin/qmake-qt5 gem install capybara-webkit
zypper install libqt4-devel libQtWebKit-devel
You can compile the source code, but adding the epel repository is way faster and easier:
sudo yum install -y epel-release
sudo yum install -y qt5-qtwebkit-devel
QMAKE=/usr/lib64/qt5/bin/qmake gem install capybara-webkit
echo 'PATH=/usr/lib64/qt5/bin:$PATH' >> ~/.bash_profile
Instead of compiling source code, add the EPEL repository and qt5-webkit-devel by performing:
sudo yum install epel-release
sudo yum install qt5-qtwebkit-devel
QMAKE=/usr/lib64/qt5/bin/qmake gem install capybara-webkit
It's that easy! If you want qmake to always work, add /usr/lib64/qt5/bin/ to your PATH variable, such as shown in the CentOS 7 example.
If you know how to compile using Qt 5 under CentOS 5.8, please edit this page and add instructions.
apk add qt5-qtwebkit-dev
QMAKE=/usr/lib/qt5/bin/qmake gem install capybara-webkit
sudo eopkg install qt5-webkit-devel
QMAKE=/usr/bin/qmake gem install capybara-webkit
On FreeBSD 11.0:
sudo pkg install qt5-webkit qt5-qmake qt5-buildtools
QMAKE=/usr/local/bin/qmake gem install capybara-webkit
The main thing in the installation below is to have the binaries for ruby, DevKit and QT, compiled for the same MinGW version, which in this case is MinGW 4.7 32 bits.
Install the 32 bits version of ruby 2.3:
https://dl.bintray.com/oneclick/rubyinstaller/rubyinstaller-2.3.3.exe
Install the 32 bits version of DevKit for MinGW 4.7:
https://dl.bintray.com/oneclick/rubyinstaller/DevKit-mingw64-32-4.7.2-20130224-1151-sfx.exe
Link DevKit and ruby following the quick start instructions:
https://github.com/oneclick/rubyinstaller/wiki/Development-Kit#quick-start
Download the 32 bits QT installer for windows:
http://download.qt.io/official_releases/online_installers/qt-unified-windows-x86-online.exe
Use the installer in the step above and install the QT 5.0.2 / MinGW 4.7 version.
Add this to your PATH environment variable:
C:\Qt\5.0.2\mingw47_32\bin
Execute this:
gem install capybara-webkit
You’ll get an error like this one: No such file or directory @ rb_sysopen - src/debug/webkit_server.exe (Errno::ENOENT)
Go to:
c:\ruby23\lib\ruby\gems\2.3.0\gems\capybara-webkit-*.*.*\src\release\
copy webkit-server.exe to a temporary location
Execute again:
gem install capybara-webkit
Before it finishes compiling copy webkit-server.exe to:
c:\ruby23\lib\ruby\gems\2.3.0\gems\capybara-webkit-*.*.*\src\debug\
After the step above, the gem should be successfully compiled.