Yarn: if integrity check won't let you start rails console

I ran into a situation in which I received the yarn integrity check warning when starting the rails console even though everything was up to date and correct versions in use.

TLDR: run spring stop

I tried starting the rails console without switching to the correct node version first and received the yarn integrity warning.

warning Integrity check: System parameters don't match                                                                                     
error Integrity check failed                                                                                                               
error Found 1 errors.                                                                                                                      


========================================
  Your Yarn packages are out of date!
  Please run `yarn install --check-files` to update.
========================================


To disable this check, please change `check_yarn_integrity`
to `false` in your webpacker config file (config/webpacker.yml).


yarn check v1.22.5
info Visit https://yarnpkg.com/en/docs/cli/check for documentation about this command.

To get this fixed I made sure, that I'm on the correct node version (nvm use to use the version from .nvmrc), ran yarn install to update node packages.
The yarn command returned success Already up-to-date, so you should be fine to start a rails console. But I still received the yarn error instead:

To really fix this I also had to stop spring by running spring stop. This will drop everything that was cached by spring.

Further reading

Most of the times you run into issues like this if you forget to switch to the correct node version before executing any command. The obvious improvement is to automatically switch node versions when changing directories.

Daniel Straßner Over 2 years ago