Ian Dickinson
Ian Dickinson

Reputation: 13305

Travis builds are failing with fatal listen error

My Travis tests for a Rails app have been working fine, but have suddenly started failing about one time in three with:

$ bundle exec rails test
FATAL: Listen error: unable to monitor directories for changes.
Visit 
https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers 
for info on how to fix this.

Looking at that suggested URL, it proposes ways to increase the number of inotify-watchers, but requires the use of sudo to change the limit. That's fine on my dev machine (though I'm actually not experiencing the error on my machine), but I don't know if that's possible (or advisable) in the Travis environment.

I looked at the Travis docs to see if there's a config setting for increasing the number of watchers, but I couldn't find anything.

So: what's the best way to deal with this error in a Travis CI test?

Upvotes: 1

Views: 790

Answers (1)

user9903
user9903

Reputation:

If you're running this on TravisCI and a CI/staging/testing server, you should not need to watch files for changes. The code should be deployed to the server, and then bundle exec rails test should run and that's it. No file watching necessary.

What I suspect is that the config for your environment is not set up correctly and that listen gem is somehow activated for the testing environment when it should only be activated for the development environment.

Try running the tests locally with the same environment as TravisCI (testing in this example):

RAILS_ENV=testing bundle exec test

and see what it says. If it gives you that error, check the config/environments/testing.rb file and look for config.cache_classes.

When config.cache_classes is set to true, the classes are cached and the listen/file-watcher will not be active. In your local development environment, config/environments/development.rb, the config.cache_classes setting should be set to false so that file-watching and reloading happens.

Upvotes: 2

Related Questions