"Could not find Firefox binary" in CircleCI

Published 6th January 2020 at 04:48am (Last Updated 22nd March 2020 at 09:20pm)

This'll be a quick-ish post as I haven't finished researching the Rails post that I actually wanted to write for this week.


Ever gotten this error before?

Could not find Firefox binary (os=linux).
Make sure Firefox is installed or set the
path manually with Selenium::WebDriver::Firefox::Binary.path=


This dude saw it in c9. Not sure why they got that error as I don't use c9 nor do I particularly trust online IDEs (vim FTW!).


I noticed it showed up in CircleCI when I tried to add the selenium gem to a rails project. It looks pretty straight-forward when you think about it, right? Just install firefox in your CircleCI container...

sudo apt-get update
sudo apt-get install libpango1.0-0
sudo apt-get install firefox


But that won't work.


firefox_fail.png54.9 KB


To be fair, running those commands in CircleCI would be a bit of a faff if it did work: it installs a bunch of dependencies and has to do this each time a test suite is run. Back when this solution still worked, some complained that it slowed down their builds.



Solution


So it turns out CircleCI already has variants of their docker images that come with a web browser pre-installed specifically for this purpose. To use those images it should be as simple as appending "-browsers" to your image name in the config.yaml file. Add "-node-browsers" if you want Node JS installed as well.


CircleCI's Ruby image with node and browsers installed



And that's it!



Told you this would be short. Hope this becomes useful to someone one day.



Further resources:




Other News:


This is the first post I've written with the ActionText/Trix text editor in Rails 6. It'll probably take a bit of getting used to if I carry on using it...more in a future post.

Post a comment