Search code examples
ruby-on-railsubuntu-18.04exit-code

bundle exec command fails but gives exitcode 0


I tried running bundle exec create_namespace command on Ubuntu. It gives error but the exitcode = 0. Is there an alternative way to capture the failure of the bundle exec create_namespace command?


Solution

  • bundle exec executes a command in the context of the bundle (from bundle exec --help ).

    If you pass a executable name that is not found, e.g. bundle exec thisisnotwhatyouarelookingfor, it will exit with a status code != 0.

    "Your" command (create_namespace) must be a self-provided script, most likely something you are working on, or something located in the repository you play around with. It is then the responsability of that script to exit with the "correct" exit code.

    You'd need to provide more information about your environment and that executable for people to dive into the issue. To find the executable yourself, a find . -name "create_namespace*" should point you in the right direction (most likely in ./binor./exe` if it is a gem and follows conventions).

    TL;DR Most likely bundle exec does not fail (it starts the create_namespace "command" in the correct environment), but the command itself fails without setting the exit code properly.