"unable to connect to chromedriver" error

I’ve just updated our rails/rspec project to chromedriver (it used to be capybara-webkit).

It’s all connecting and executing ok locally but when I put it onto Circle, the machine isn’t managing to find the chromedriver:

       unable to connect to chromedriver

Circle config

The pertinent details of my circle config file are below:

 - checkout
 - restore_cache: # Restore bundle cache
       - v2-dependencies-{{ checksum "Gemfile.lock" }}
       - v2-dependencies-
 - browser-tools/install-browser-tools
 - run:
     name: run tests
     command: bundle exec rspec --drb --colour --format documentation --order rand --format RspecJunitFormatter --out /tmp/circleci-test-results/rspec.xml $TEST_FILES

Verifying that chromedriver is installed…

If I SSH into the box I can verify that both Chrome and chromedriver are present but for some reason I can’t connect to them in the tests:

$ chromedriver --version
# => ChromeDriver 73.0.3683.68 (47787ec04b6e38e22703e856e101e840b65afe72)

$ google-chrome --version
# => Google Chrome 73.0.3683.103 

I’m sure there’s something simple I’m missing but what it is is a mystery…

You could try waiting for a bit (sleep or using listener detection) before running the tests - maybe the Chromedriver listener takes a while to start up?

Did you manage to figure out what was causing this?

I did yes. I managed to fix it by bumping the circleci cache key. I don’t know why the cache was the issue and it took forever to narrow it down to that but when I altered the key and forced a rebuild it started working.