twpayne/chezmoi

Make `chezmoi status` more helpful if template can't be rendered or file decrypted

Closed this issue · 1 comments

Is your feature request related to a problem? Please describe.

If some file can't be rendered or decrypted, chezmoi status only shows that error and no information about list of files chezmoi apply is going to change. Also it shows only the first error if there are multiple.

For example, here ruff is not installed. But there is run_before_ script which installs it. So in fact chezmoi apply will succeed. But user can't see if that script is going to run using chezmoi status.

$ uv tool uninstall ruff
$ chezmoi add --template .config/zsh/custom_completion/_ruff
$ cat $(chezmoi source-path .config/zsh/custom_completion/_ruff)
{{- output "ruff" "generate-shell-completion" "zsh" -}}
$ chezmoi status --verbose
chezmoi: .config/zsh/custom_completion/_ruff: template: dot_config/zsh/custom_completion/_ruff.tmpl:1:4: executing "dot_config/zsh/custom_completion/_ruff.tmpl" at <output "ruff" "generate-shell-completion" "zsh">: error calling output: ruff generate-shell-completion zsh: exec: "ruff": executable file not found in $PATH

Describe the solution you'd like

Show list of files chezmoi apply is going to modify. Show new error state for those which can't be rendered or decrypted. Print current error messages for those files to stderr (like chezmoi does now for the first error).

Describe alternatives you've considered

Exclude affected types manually or include interesting:

$ chezmoi status -i scripts

Still no way to see the full list. And it doesn't work if script which runs later depends on something installed by previous script. E.g. first one installs gpg and the second one is encrypted.

Show list of files chezmoi apply is going to modify. Show new error state for those which can't be rendered or decrypted. Print current error messages for those files to stderr (like chezmoi does now for the first error).

You can use

$ chezmoi apply --dry-run --keep-going --verbose

for this.