Describe the bug
The pattern matching for .chezmoiignore and .chezmoiremove ignores trailing slashes in a pattern.
To reproduce
Here I only mention about .chezmoiignore:
- Prepare files:
mkdir -p ~/d1/d2
touch ~/d1/p ~/d1/d2/q
- Add files:
$ chezmoi managed | grep '^d1'
d1
d1/d2
d1/d2/q
d1/p
- Add the following pattern to
.chezmoiignore:
- List managed files:
chezmoi managed | grep '^d1'
Expected behavior
chezmoi ignores d2 (and its content q):
Output of command with the --verbose flag
Actually, it ignores everything under d1 including file p:
$ chezmoi --verbose managed | grep '^d1'
d1
Output of chezmoi doctor
Details
$ chezmoi doctor
RESULT CHECK MESSAGE
ok version v2.70.3, commit ff6317e356645f92976ac8695424735cadbd5a3b, built at 2026-05-07T20:57:18Z, built by goreleaser
ok latest-version v2.70.3
ok os-arch linux/amd64 (Ubuntu 24.04.4 LTS (Noble Numbat))
ok build-info -ldflags=-s -w -X main.version=2.70.3 -X main.commit=ff6317e356645f92976ac8695424735cadbd5a3b -X main.date=2026-05-07T20:57:18Z -X main.builtBy=goreleaser, CGO_ENABLED=1, GOAMD64=v1
ok uname Linux TP-T14-G5-Ubuntu 6.17.0-23-generic #23~24.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue Apr 14 16:11:48 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
ok go-version go1.26.3 (gc)
ok executable ~/.local/share/mise/installs/chezmoi/2.70.3/chezmoi
ok upgrade-method replace-executable
ok config-file found ~/.config/chezmoi/chezmoi.toml, last modified 2026-05-09T07:47:15+09: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
ok hardlink created hardlink from ~/.local/share/chezmoi to /tmp
ok symlink created symlink from .new-name to .old-name
ok umask 002
ok cd-command found /usr/bin/fish
ok cd-args /usr/bin/fish
info diff-command not set
ok edit-command found /usr/bin/nano
ok edit-args /usr/bin/nano
ok git-command found /usr/bin/git, version 2.43.0
warning merge-command vimdiff not found in $PATH
ok shell-command found /usr/bin/fish
ok shell-args /usr/bin/fish
info age-command age not found in $PATH
ok gpg-command found /usr/bin/gpg, version 2.4.4
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
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 protonpass-command pass-cli 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
Additional context
It was derived from #4636.
I think some people (including me) confuse it with .gitignore’s pattern matching. Additional documentation may be helpful.
Describe the bug
The pattern matching for
.chezmoiignoreand.chezmoiremoveignores trailing slashes in a pattern.To reproduce
Here I only mention about
.chezmoiignore:chezmoi add ~/d1.chezmoiignore:Expected behavior
chezmoi ignores
d2(and its contentq):Output of command with the
--verboseflagActually, it ignores everything under
d1including filep:Output of
chezmoi doctorDetails
Additional context
It was derived from #4636.
I think some people (including me) confuse it with
.gitignore’s pattern matching. Additional documentation may be helpful.