Closed rlue closed 2 months ago
Thanks for spotting this. This is an interesting case of non-orthogonality in chezmoi.
The tl;dr is that .chezmoiremove
is a separate system to chezmoi's source state and they don't interact well. Use the remove_
attribute on the directory instead.
Note that this is not specific to exact_
directories, so I'll ignore exact_
.
In a sense, the configuration that you have is inconsistent: it states that foo
and foo/bar
should exist (because they are present in the source state) and also that foo
should be removes. The reason that chezmoi does not detect the inconsistency is because chezmoi's order of operations is roughly:
.chezmoiremove
lines.In your case, foo
does not exist at stage 2, so it is not added to the list, and therefore created in stage 3 and not removed in stage 4.
Instead, use the remove_
attribute on foo
, which will tell chezmoi to remove the directory if it is empty.
Hopefully this is now resolved. Please re-open if needed.
Describe the bug
This is not a bug in a strict sense; chezmoi is not behaving the way I expect it to, and I hope to make the case here that my expectations agree with how it should work.
I would like to:
exact_
directory in my source dir.chezmoiremove
chezmoi diff
shows that it would add the directory to my target dir, but I would expect.chezmoiremove
to take precedence over a file attribute, since the former offers more expressive and fine-grained control than the latter.It appears that adding the file to
.chezmoiignore
as well resolves this problem—but leaves us having to duplicate entries between the two files. So perhaps another way of stating this "bug" report is that, IMO, entries in.chezmoiremove
should be implicitly ignored, as well.To reproduce
Expected behavior
foo
should not appear in the diff.Why?
Of course, there are more complex cases where the correct behavior is not so clear. What if we list a file in
.chezmoiremove
that is within anexact_
directory?but
IMO, the behavior of
.chezmoiremove
here should mirror that of.chezmoiignore
—which currently ignores the listed file and generates a non-exact copy of the directoryfoo
.Output of command with the
--verbose
flagOutput of
chezmoi doctor
Additional context
N/A