Skip to content

remove_ directory action not shown in chezmoi status #4652

@rightaditya

Description

@rightaditya

Describe the bug

If a directory that has the remove_ source attribute would be removed by chezmoi apply, chezmoi status should indicate as much, but it doesn't. This seems to affect remove_ directories only, not remove_ files.

To reproduce

$ mkdir test
$ chezmoi add test
$ chezmoi chattr +remove test
$ chezmoi status
$ chezmoi apply
$ stat test
stat: cannot statx 'test': No such file or directory

Expected behavior

$ mkdir test
$ chezmoi add test
$ chezmoi chattr +remove test
$ chezmoi status
 D test
$ chezmoi apply
$ stat test
stat: cannot statx 'test': No such file or directory

This would be consistent with the different (and, I believe, correct) current behaviour for files:

$ touch test
$ chezmoi add test
$ chezmoi chattr +remove test
$ chezmoi status
 D test
$ chezmoi apply
$ stat test
stat: cannot statx 'test': No such file or directory

Output of command with the --verbose flag

$ mkdir test
$ chezmoi add -v test
diff --git a/test b/test
new file mode 40750
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
--- /dev/null
+++ b/test
diff --git a/test/.keep b/test/.keep
new file mode 100640
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
--- /dev/null
+++ b/test/.keep
$ chezmoi chattr -v +remove test
diff --git a/test b/remove_test
rename from test
rename to remove_test
$ chezmoi status -v
$ chezmoi apply -v
diff --git a/.local/state/dconf.sh b/.local/state/dconf.sh
new file mode 100755
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
--- /dev/null
+++ b/.local/state/dconf.sh
diff --git a/test b/test
deleted file mode 40750
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000
--- a/test
+++ /dev/null
$ stat test
stat: cannot statx 'test': No such file or directory

Output of chezmoi doctor

$ chezmoi doctor
RESULT    CHECK                       MESSAGE
warning   version                     v2.65.1, built at 2025-09-09T23:21:13Z
ok        latest-version              v2.65.1
ok        os-arch                     linux/amd64 (CachyOS Linux)
ok        uname                       Linux capsaicin 6.16.6-3-cachyos #1 SMP PREEMPT_DYNAMIC Wed, 10 Sep 2025 17:00:19 +0000 x86_64 GNU/Linux
ok        go-version                  go1.25.1 X:nodwarf5 (gc)
ok        executable                  /usr/bin/chezmoi
ok        config-file                 found ~/.config/chezmoi/chezmoi.toml, last modified 2025-04-23T15:48:26-04:00
warning   source-dir                  ~/.local/share/chezmoi is a git working tree (dirty)
ok        suspicious-entries          no suspicious entries
warning   working-tree                ~/.local/share/chezmoi is a git working tree (dirty)
ok        dest-dir                    ~ is a directory
error     hardlink                    failed creating hardlink from ~/.local/share/chezmoi to /run/user/1000: link ~/.local/share/chezmoi/.chezmoi-doctor-hardlink-test /run/user/1000/chezmoi-doctor792007854/.chezmoi-doctor-hardlink-test: invalid cross-device link
warning   umask                       027
ok        cd-command                  found /bin/fish
ok        cd-args                     /bin/fish
info      diff-command                not set
ok        edit-command                found /usr/bin/nvim
ok        edit-args                   /usr/bin/nvim
ok        git-command                 found /usr/bin/git, version 2.51.0
ok        merge-command               found /usr/bin/meld
ok        shell-command               found /bin/fish
ok        shell-args                  /bin/fish
ok        age-command                 found /usr/bin/age, version 1.2.1
ok        gpg-command                 found /usr/bin/gpg, version 2.4.8
info      pinentry-command            not set
ok        1password-command           found /usr/bin/op, version 2.31.1
info      bitwarden-command           bw not found in $PATH
info      bitwarden-secrets-command   bws not found in $PATH
info      dashlane-command            dcli not found in $PATH
info      doppler-command             doppler not found in $PATH
info      gopass-command              gopass not found in $PATH
info      keepassxc-command           keepassxc-cli not found in $PATH
info      keepassxc-db                not set
info      keeper-command              keeper not found in $PATH
info      lastpass-command            lpass not found in $PATH
info      pass-command                pass not found in $PATH
info      passhole-command            ph not found in $PATH
info      rbw-command                 rbw not found in $PATH
info      vault-command               vault not found in $PATH
info      secret-command              not set

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpatiencePatience required, there is no date for this being fixedv3Planned for v3

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions