anishathalye / dotbot

A tool that bootstraps your dotfiles ⚡️
MIT License
6.91k stars 288 forks source link

How to continue profile installation when an error is raised? #299

Closed Vafa-Andalibi closed 2 years ago

Vafa-Andalibi commented 2 years ago

I'm creating a profile which has multiple configs. When any error is raised in any of the configs, the next config will not run and the execution stops at the end of that config file.

This makes the profile installation process very fragile. How can I continue to the next config file even if an error is raised?

Thanks

Vafa-Andalibi commented 2 years ago

This exit() was the culprit:

https://github.com/anishathalye/dotbot/blob/769767c129c8f26eb66dca06dfa4a1bddbac8a9e/dotbot/cli.py#L162

Why should this be here? isn't logging it sufficient?

anishathalye commented 2 years ago

It makes sense to have Dotbot signal an error to the environment when there is an error.

I'm guessing you are using https://github.com/anishathalye/dotbot/wiki/Tips-and-Tricks#install-profile ? That script uses set -e, so it bails out on error. If you don't want that behavior, you could modify the script to explicitly ignore the return code from the Dotbot invocation, e.g. with:

- "${cmd[@]}"
+ "${cmd[@]}" || true
Vafa-Andalibi commented 2 years ago

Sounds good, thanks!