Closed ja1den closed 1 year ago
The empty_
attribute only applies to files. Using empty_
as part of a directory name results in the literal empty_
in the target directory name. This is visible in the output of chezmoi --verbose apply
and the output of chezmoi --verbose managed
.
To fix this, it should be sufficient to remove the empty_
prefix from empty_directory4
and add directory4
to your .chezmoiignore
file.
Describe the bug
Directories in the source state with no content, or with all their content
.chezmoiignore
d, are still created in the target state when runningchezmoi apply
.It also seems like the
empty_
attribute does nothing when applied to directories, which, in light of #754, seems to be wrong:From this, I'd assume that directories in the source state with no content, or with all their content
.chezmoiignore
d, would be ignored bychezmoi apply
. However, I'd still expect directories with theempty_
attribute to be created.Finally, I'd also feel like, when this is fixed, directories ignored by
chezmoi apply
should also be absent fromchezmoi managed
. However, this isn't the primary issue, just something that's worth considering later on.To reproduce
Create the following directory structure (for the source state):
Add the following to
.chezmoignore
:Add the following to
directory2/config
:Add the following to
directory3/config
:Expected behavior
Running
chezmoi apply
currently yields the following in the target state:Instead, I'd expect it to produce the following:
Similarly, running
chezmoi managed
currently yields the following:Instead, I'd expect it to produce the following:
In both cases,
directory1
is empty, so it is ignored. Similarly,directory2
has all its content.chezmoiignore
d, so it is ignored as well.Output of command with the
--verbose
flagOutput of
chezmoi doctor
I ran all the above commands with a pair of test directories (
source
anddestination
), which is why the paths reported bychezmoi doctor
are different. Specifically, I had-S ./source -D ./destination
at the end of each command.The full paths to my test directories were
~/.local/share/chezmoi/source
and~/.local/share/chezmoi/destination
(Yes, I made them within my existing config. I would have made them somewhere else, but it shouldn't have made a difference).Additional context
I noticed this problem when I saw that
chezmoi apply
was still creating my.scripts
directory, even when I'd.chezmoiignore
d all the files inside it (It contains severalbash
scripts, which I don't want copied when I'm on windows).