Skip to content

Using chezmoi destory <folder synced by chezmoiexternal.toml> Will cause the entire chezmoi HOME folder to be cleaned or deleted. #4745

@ylchen07

Description

@ylchen07

Describe the bug

Using chezmoi destory <folder synced by chezmoiexternal.toml> Will cause the entire chezmoi HOME folder to be cleaned or deleted.

To reproduce

  1. Define a git-repo in the external.toml file to sync it with some local directory
  2. use chezmoi destory command to remove the folder in sync under ~ , not in the chezmoi HOME folder
  3. You will find all the content inside default chezmoi path get cleaned .local/share/chezmoi become an empty folder.

Expected behavior

  1. forbbiden to use destory command to clean a folder that user don't want in-sync any more.
  2. chezmoi destory a sync folder will lead chezmoi change the external config file automatically

Output of command with the --verbose flag

Image

Output of chezmoi doctor

$ chezmoi doctor
RESULT    CHECK                       MESSAGE
ok        version                     v2.66.1, commit 94b95eb0b6bf91e48dd7b584a80ad60d44d8de4d, built at 2025-10-19T22:03:22Z, built by Homebrew
ok        latest-version              v2.66.1
ok        os-arch                     linux/amd64 (Fedora Linux 42 (Workstation Edition))
ok        uname                       Linux MTL-CA763.ubisoft.org 6.17.5-200.fc42.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Oct 24 14:10:01 UTC 2025 x86_64 GNU/Linux
ok        go-version                  go1.25.3 (gc)
ok        executable                  /home/linuxbrew/.linuxbrew/Cellar/chezmoi/2.66.1/bin/chezmoi
ok        upgrade-method              brew-upgrade
ok        config-file                 found ~/.config/chezmoi/chezmoi.yaml, last modified 2025-10-28T12:20:53-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 /tmp: link ~/.local/share/chezmoi/.chezmoi-doctor-hardlink-test /tmp/chezmoi-doctor1700788802/.chezmoi-doctor-hardlink-test: invalid cross-device link
ok        umask                       022
ok        cd-command                  found /usr/bin/zsh
ok        cd-args                     /usr/bin/zsh
info      diff-command                not set
ok        edit-command                found /home/linuxbrew/.linuxbrew/bin/nvim
ok        edit-args                   /home/linuxbrew/.linuxbrew/bin/nvim
ok        git-command                 found /usr/bin/git, version 2.51.0
ok        merge-command               found /usr/bin/vimdiff
ok        shell-command               found /usr/bin/zsh
ok        shell-args                  /usr/bin/zsh
info      age-command                 age not found in $PATH
ok        gpg-command                 found /home/linuxbrew/.linuxbrew/bin/gpg, version 2.4.8
info      pinentry-command            not set
info      1password-command           op not found in $PATH
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
ok        gopass-command              found /home/linuxbrew/.linuxbrew/bin/gopass, version 1.15.18
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
ok        vault-command               found /home/linuxbrew/.linuxbrew/bin/vault, version 1.20.4
ok        secret-command              found /home/linuxbrew/.linuxbrew/bin/gh

Additional context

Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions