panic: nodes[1]: unexpected non-terminal source state entry, got *chezmoi.SourceStateCommand
Describe the bug
I'm trying to manage a custom theme within a chemoizexternal-managed directory:
$ chezmoi --verbose add .oh-my-zsh/custom/themes/hannah.zsh-theme
panic: nodes[1]: unexpected non-terminal source state entry, got *chezmoi.SourceStateCommand
goroutine 1 [running]:
chezmoi.io/chezmoi/internal/chezmoi.(*SourceState).Add(0x140003fda00, {0x103d195c0, 0x140000cefa0}, {0x103d12530, 0x14000143ae0}, {0x103d195c0, 0x140000ceff0}, 0x1400025a210, 0x14000173760)
chezmoi.io/chezmoi/internal/chezmoi/sourcestate.go:460 +0x1ba4
chezmoi.io/chezmoi/internal/cmd.(*Config).runAddCmd(0x1400028d008, 0x14000232c08?, {0x14000420aa0?, 0x0?, 0x0?}, 0x140003fda00)
chezmoi.io/chezmoi/internal/cmd/addcmd.go:231 +0x4a8
chezmoi.io/chezmoi/internal/cmd.(*Config).newAddCmd.(*Config).makeRunEWithSourceState.func2(0x14000232c08, {0x14000420aa0, 0x1, 0x2})
chezmoi.io/chezmoi/internal/cmd/config.go:1825 +0x84
github.com/spf13/cobra.(*Command).execute(0x14000232c08, {0x14000420a80, 0x2, 0x2})
github.com/spf13/[email protected]/command.go:1015 +0x7d4
github.com/spf13/cobra.(*Command).ExecuteC(0x14000232608)
github.com/spf13/[email protected]/command.go:1148 +0x350
github.com/spf13/cobra.(*Command).Execute(...)
github.com/spf13/[email protected]/command.go:1071
chezmoi.io/chezmoi/internal/cmd.(*Config).execute(0x1400028d008, {0x140001b4050, 0x3, 0x3})
chezmoi.io/chezmoi/internal/cmd/config.go:1390 +0x98
chezmoi.io/chezmoi/internal/cmd.runMain({{0x1038f7b84, 0x6}, {0x1038f8ca0, 0x28}, {0x1038f8a20, 0x14}, {0x1038f8918, 0x8}}, {0x140001b4050, 0x3, ...})
chezmoi.io/chezmoi/internal/cmd/cmd.go:216 +0x170
chezmoi.io/chezmoi/internal/cmd.Main({{0x1038f7b84, 0x6}, {0x1038f8ca0, 0x28}, {0x1038f8a20, 0x14}, {0x1038f8918, 0x8}}, {0x140001b4050, 0x3, ...})
chezmoi.io/chezmoi/internal/cmd/cmd.go:58 +0x1b0
main.main()
chezmoi.io/chezmoi/main.go:27 +0xaccontent of .chezmoiexternal.toml
[".oh-my-zsh"]
type = "git-repo"
url = "https://github.com/ohmyzsh/ohmyzsh.git"
refreshPeriod = "168h"
[".oh-my-zsh/custom/plugins/zsh-autosuggestions"]
type = "git-repo"
url = "https://github.com/zsh-users/zsh-autosuggestions.git"
refreshPeriod = "168h"
[".oh-my-zsh/custom/plugins/zsh-syntax-highlighting"]
type = "git-repo"
url = "https://github.com/zsh-users/zsh-syntax-highlighting.git"
refreshPeriod = "168h"Expected behavior
I expected the file to be copied to ~/.local/share/chezmoi/dot_oh-my-zsh/custom/themes and managed.
But manually creating a file in the repo & applying it gives me:
$ mkdir -p ~/.local/share/chezmoi/dot_oh-my-zsh/custom/themes
$ echo "test" > ~/.local/share/chezmoi/dot_oh-my-zsh/custom/themes/test.txt
$ chezmoi apply
chezmoi: .oh-my-zsh: inconsistent state (/Users/hannah/.local/share/chezmoi/dot_oh-my-zsh, https://github.com/ohmyzsh/ohmyzsh.git defined in /Users/hannah/.local/share/chezmoi/.chezmoiexternal.toml)So I'm guessing that usage isn't supported, but that's not very clear: https://www.chezmoi.io/user-guide/include-files-from-elsewhere/#include-a-subdirectory-from-a-git-repository has a box saying
Hint
If you need to manage extra files in a git-repo external, use an archive external instead with the URL pointing to an archive of the git repo's master or main branch.
Which I guess is supposed to cover what I'm trying here, but doesn't actually explicitly say that this doesn't work -- and ideally the tooling would also just tell me that, e.g. attempting that chezmoi add call above should fail with an error message like "can't manage files inside a .chezmoiexternal git-repo, switch to archive instead"
Output of chezmoi doctor
$ chezmoi doctor
RESULT CHECK MESSAGE
ok version v2.69.0, commit 562f9716b6d3690abd854f6a4ffab73a56595884, built at 2026-01-04T23:27:37Z, built by Homebrew
ok latest-version v2.69.0
ok os-arch darwin/arm64
ok uname Darwin Hannahs-MBP.localdomain 25.2.0 Darwin Kernel Version 25.2.0: Tue Nov 18 21:09:56 PST 2025; root:xnu-12377.61.12~1/RELEASE_ARM64_T6041 arm64
ok go-version go1.25.5 (gc)
ok executable /opt/homebrew/bin/chezmoi
ok upgrade-method brew-upgrade
ok config-file found ~/.config/chezmoi/chezmoi.toml, last modified 2026-01-07T12:45:59Z
ok source-dir ~/.local/share/chezmoi is a git working tree (clean)
warning suspicious-entries ~/.local/share/chezmoi/.git/fsmonitor--daemon.ipc
ok working-tree ~/.local/share/chezmoi is a git working tree (clean)
ok dest-dir ~ is a directory
ok hardlink created hardlink from ~/.local/share/chezmoi to /var/folders/v_/qxd63ncj7k97vg47sn1hn0800000gn/T/
ok symlink created symlink from .new-name to .old-name
ok umask 022
ok cd-command found /bin/zsh
ok cd-args /bin/zsh
info diff-command not set
ok edit-command found /opt/homebrew/bin/nvim
ok edit-args /opt/homebrew/bin/nvim
ok git-command found /opt/homebrew/bin/git, version 2.52.0
ok merge-command found /usr/bin/vimdiff
ok shell-command found /bin/zsh
ok shell-args /bin/zsh
info age-command age not found in $PATH
ok gpg-command found /usr/local/bin/gpg, version 2.2.41
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 setSource: twpayne/chezmoi