Rails build fails with message 'error Command "webpack" not found' or 'error Command "bundler" not found'

This error means that a necessary binary is not found. This is because, for some reason, it is not being installed as part of “rails assets:precompile” in your project.

Two possible solutions that you can try:

  1. As described here and here, if your project does not have the correct binstub then “rails assets:precompile” may not run the “install” command as part of the compilation. We suggest you regenerate your Rails binstubs.

  2. If you’re unable to get to the bottom of this, you could just install the binary in the “after_checkout” or “after_bundle” deploy hook

You can manually regenerate your binstubs using this Bundler command:

bundle config --delete bin
rails app:update:bin
git add bin