Search code examples
qthomebrewqtwebkitcapybara-webkit

Can I use homebrew's qt5 with capybara-webkit?


I want to use qt5's QtWebKit with capybara-webkit.

brew uninstall qt
Uninstalling /usr/local/Cellar/qt/4.8.4...
brew install qt5
This formula is keg-only: so it was not symlinked into /usr/local.
🍺  /usr/local/Cellar/qt5/5.0.2: 3103 files, 140M, built in 60.9 minutes

If I force brew to create the symlinks for qt5 I can build the native extension for capybara-webkit ..

brew link --force qt5
Linking /usr/local/Cellar/qt5/5.0.2... 122 symlinks created
gem install capybara-webkit -v '1.0.0'
Successfully installed capybara-webkit-1.0.0

.. but webkit_server crashes hard ..

bundle exec rake test:integration
Errno::EADDRNOTAVAIL: Can't assign requested address - connect(2)
dyld: Library not loaded: /private/tmp/qt5-KytU/qt-everywhere-opensource-src-5.0.2/qtwebkit/lib/QtWebKit.framework/Versions/5/QtWebKit
  Referenced from: /usr/local/opt/qt5/lib/QtWebKitWidgets.framework/Versions/5/QtWebKitWidgets
  Reason: image not found

See full osx crash report.

I tried installing capybara-webkit with LDFLAGS and CPPFLAGS but webkit_server still crashes hard.

env LDFLAGS=-L/usr/local/opt/qt5/lib \
  CPPFLAGS=-I/usr/local/opt/qt5/include \
  gem install capybara-webkit -v '1.0.0'

Solution

  • Two years later, the same steps from my question now work. Thanks, whoever fixed it.

    gem uninstall --all capybara-webkit
    brew remove qt
    brew install qt5
    brew linkapps qt5 # optional?
    brew link --force qt5
    gem install capybara-webkit
    

    After installing qt5, I no longer see this message from my test suite:

    WARNING: The next major version of capybara-webkit will require at least version 5.0 of Qt.
    

    Uninstalling the capybara gem is not necessary (as other answers suggest) because it has no native extensions, thus no direct dependency on QT.