thoughtbot / capybara-webkit

A Capybara driver for headless WebKit to test JavaScript web apps
https://thoughtbot.com/open-source
MIT License
1.97k stars 428 forks source link

Lauching webkit_server from Heroku Puma app server failing with shared library error #1043

Open mikedalpee opened 6 years ago

mikedalpee commented 6 years ago

I have spent an enormous amount of time getting capybara-webkit to build on Heroku. Everything that supports the webkit is installed under the apps local directory directory, and environment variables are set to point at the libraries and binaries it contains. Now that I have finally got everything in place, I am getting a very odd problem when I launch my app and try to create a session:

2017-12-10T02:35:04.046338+00:00 app[web.1]: /app/vendor/bundle/ruby/2.4.0/gems/capybara-webkit-1.1.0/bin/webkit_server: error while loading shared libraries: libGL.so.1: cannot open shared object file: No such file or directory

Thing is, the library exists and LD_LIBRARY_PATH is set properly so it can be found. If I create a Heroku bash terminal and run webkit-server manually, I get:

QXcbConnection: Could not connect to display Aborted

So it is at least seeing libGL.so.1 properly. Could this just be that when the webkit-server is spawned, it is somehow not inheriting the environment variables from the Dyno? If so, is there any way I can set them such that webkit-server can see them?

UPDATE: After running some tests locally, I found that Puma workers do not inherit their parent's environment variables. UPDATE: Using puma's on_worker_boot feature, I was able to set LD_LIBRARY_PATH and verify it is set correctly. However, webkit still does not appear to be getting it passed when it is spawned - it is still unable to load libGL.so.1 even though it is in the directory LD_LIBRARY_PATH points to.