Make error installing capybara-webkit

I’m geting the following error trying to install capybara-webkit…

Version.cpp: In member function ‘virtual void Version::start()’:
Version.cpp:11: error: ‘QTWEBKIT_VERSION_STR’ was not declared in this scope
make[1]: *** [Version.o] Error 1
make[1]: Leaving directory `/usr/lib/ruby/gems/1.9.1/gems/capybara-webkit-1.0.0/src'
make: *** [sub-src-webkit_server-pro-make_default-ordered] Error 2
Command 'make' failed

This is among a lot of output after running sudo gem install capybara-webkit. It’s on an Ubuntu VM.

Any ideas?

Have you installed Qt? capybara-webkit depends on it. This page from the capybara-webkit wiki explains how to install Qt for various operating systems.

Installing gems with sudo is typically a bad idea (see this blog post for more info on why). capybara-webkit is usually included in the Gemfile rather than installed manually.

group :test do
  gem 'capybara-webkit'

Yup, I should have said that I already installed libqt4-dev (per that page). That install went flawlessly. But now I’m getting this error. bundler gives the same ‘make’ error, and then says “Make sure that gem install capybara-webkit -v '1.0.0' succeeds before bundling.” And, of course, that gives the error “You don’t have write permissions into the /usr/lib/ruby/gems/1.9.1 directory”, which is why I had resorted to sudo.

Are you using some kind of ruby version manager such as RVM, rbenv, or chruby?

No, I wish. It’s a VM setup to mimic the production env and just using system ruby. This is not something I can change at this time.