twpayne/chezmoi

`chezmoid apply` (and `dump`) cause a Go panic

Closed this issue · 3 comments

Describe the bug

Updated to 2.48.0 and it works on all of my machines except in one LXC container (where it used to work). cz apply (and dump, but not dump-config) cause a Go panic:

$ chezmoi dump
Caught panic:

tea.unknownCSISequenceMsg: unknown message type

Restoring terminal...

goroutine 1 [running]:
runtime/debug.Stack()
	/opt/hostedtoolcache/go/1.22.2/x64/src/runtime/debug/stack.go:24 +0x5e
runtime/debug.PrintStack()
	/opt/hostedtoolcache/go/1.22.2/x64/src/runtime/debug/stack.go:16 +0x13
github.com/charmbracelet/bubbletea.(*Program).Run.func1()
	/home/runner/go/pkg/mod/github.com/charmbracelet/bubbletea@v0.25.0/tea.go:478 +0x91
panic({0x12b4ec0?, 0xc00051c060?})
	/opt/hostedtoolcache/go/1.22.2/x64/src/runtime/panic.go:770 +0x132
github.com/twpayne/chezmoi/v2/internal/cmd.httpSpinnerModel.Update({{0xc00081e600, 0x43}, {{{0xc0008f0008, 0x4a, 0x4a}, 0xfe502a}, {0x0, 0x0, {0x0, 0x0}}, ...}, ...}, ...)
	/home/runner/work/chezmoi/chezmoi/internal/cmd/readhttpresponse.go:107 +0x514
github.com/charmbracelet/bubbletea.(*Program).eventLoop(0xc0005d2b60, {0x19a1630?, 0xc0004163f0?}, 0xc0000b2960)
	/home/runner/go/pkg/mod/github.com/charmbracelet/bubbletea@v0.25.0/tea.go:411 +0x5e2
github.com/charmbracelet/bubbletea.(*Program).Run(0xc0005d2b60)
	/home/runner/go/pkg/mod/github.com/charmbracelet/bubbletea@v0.25.0/tea.go:543 +0x86b
github.com/twpayne/chezmoi/v2/internal/cmd.runReadHTTPResponse({0x19a48d0?, 0xc0004163f0?}, 0xc0001263f0)
	/home/runner/work/chezmoi/chezmoi/internal/cmd/readhttpresponse.go:184 +0x18f
github.com/twpayne/chezmoi/v2/internal/cmd.(*Config).readHTTPResponse(0xc0006aa008?, 0xc0001263f0)
	/home/runner/work/chezmoi/chezmoi/internal/cmd/readhttpresponse.go:151 +0x3e5
github.com/twpayne/chezmoi/v2/internal/chezmoi.(*SourceState).getExternalDataRaw(0xc000380c00, {0x19a49b0, 0x23b85c0}, {{0xc0004619b0?, 0xc0006993c0?}}, 0xc00012bd40, 0xc000135c80)
	/home/runner/work/chezmoi/chezmoi/internal/chezmoi/sourcestate.go:1586 +0x414
github.com/twpayne/chezmoi/v2/internal/chezmoi.(*SourceState).getExternalData(0xc000380c00, {0x19a49b0?, 0x23b85c0?}, {{0xc0004619b0?, 0x7ef6efbba5b8?}}, 0xc00012bd40, 0xc0006a8808?)
	/home/runner/work/chezmoi/chezmoi/internal/chezmoi/sourcestate.go:1617 +0x5a
github.com/twpayne/chezmoi/v2/internal/chezmoi.(*SourceState).readExternalFile.func1()
	/home/runner/work/chezmoi/chezmoi/internal/chezmoi/sourcestate.go:2650 +0x2f
github.com/twpayne/chezmoi/v2/internal/chezmoi.(*lazyContents).Contents(0xc0004156d0)
	/home/runner/work/chezmoi/chezmoi/internal/chezmoi/lazy.go:77 +0x33
github.com/twpayne/chezmoi/v2/internal/chezmoi.(*TargetStateFile).EntryState(0xc0004311d0, 0x2)
	/home/runner/work/chezmoi/chezmoi/internal/chezmoi/targetstateentry.go:234 +0x26
github.com/twpayne/chezmoi/v2/internal/chezmoi.(*SourceState).Apply(0xc000380c00, {0x19ade90, 0xc0003ba838}, {0x19ae0a0, 0xc0003db320}, {0x19aaa58, 0xc0003ba298}, {0x0, 0x0}, {{0xc000461f20, ...}}, ...)
	/home/runner/work/chezmoi/chezmoi/internal/chezmoi/sourcestate.go:703 +0x1e3
github.com/twpayne/chezmoi/v2/internal/cmd.(*Config).applyArgs(0xc0006aa008, {0x19a49b0, 0x23b85c0}, {0x19ade90, 0xc0003ba838}, {0x0, 0x0}, {0x23b85c0, 0x0, 0x0}, ...)
	/home/runner/work/chezmoi/chezmoi/internal/cmd/config.go:653 +0x69f
github.com/twpayne/chezmoi/v2/internal/cmd.(*Config).runDumpCmd(0xc0006aa008, 0xc000779808, {0x23b85c0, 0x0, 0x0})
	/home/runner/work/chezmoi/chezmoi/internal/cmd/dumpcmd.go:40 +0x154
github.com/spf13/cobra.(*Command).execute(0xc000779808, {0x23b85c0, 0x0, 0x0})
	/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:983 +0xaca
github.com/spf13/cobra.(*Command).ExecuteC(0xc0001b9808)
	/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1115 +0x3ff
github.com/spf13/cobra.(*Command).Execute(...)
	/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1039
github.com/twpayne/chezmoi/v2/internal/cmd.(*Config).execute(0xc0006dfde8?, {0xc000040050, 0x1, 0x1})
	/home/runner/work/chezmoi/chezmoi/internal/cmd/config.go:1227 +0x78
github.com/twpayne/chezmoi/v2/internal/cmd.runMain({{0x1990354, 0x6}, {0x19a15a0, 0x28}, {0x1995070, 0x14}, {0x1991318, 0xa}}, {0xc000040050, 0x1, ...})
	/home/runner/work/chezmoi/chezmoi/internal/cmd/cmd.go:270 +0x25c
github.com/twpayne/chezmoi/v2/internal/cmd.Main({{0x1990354, 0x6}, {0x19a15a0, 0x28}, {0x1995070, 0x14}, {0x1991318, 0xa}}, {0xc000040050, 0x1, ...})
	/home/runner/work/chezmoi/chezmoi/internal/cmd/cmd.go:106 +0xa5
main.main()
	/home/runner/work/chezmoi/chezmoi/main.go:24 +0xfb
panic: interface conversion: interface is nil, not cmd.cancelableModel

goroutine 1 [running]:
github.com/twpayne/chezmoi/v2/internal/cmd.runReadHTTPResponse({0x19a48d0?, 0xc0004163f0?}, 0xc0001263f0)
	/home/runner/work/chezmoi/chezmoi/internal/cmd/readhttpresponse.go:186 +0x25d
github.com/twpayne/chezmoi/v2/internal/cmd.(*Config).readHTTPResponse(0xc0006aa008?, 0xc0001263f0)
	/home/runner/work/chezmoi/chezmoi/internal/cmd/readhttpresponse.go:151 +0x3e5
github.com/twpayne/chezmoi/v2/internal/chezmoi.(*SourceState).getExternalDataRaw(0xc000380c00, {0x19a49b0, 0x23b85c0}, {{0xc0004619b0?, 0xc0006993c0?}}, 0xc00012bd40, 0xc000135c80)
	/home/runner/work/chezmoi/chezmoi/internal/chezmoi/sourcestate.go:1586 +0x414
github.com/twpayne/chezmoi/v2/internal/chezmoi.(*SourceState).getExternalData(0xc000380c00, {0x19a49b0?, 0x23b85c0?}, {{0xc0004619b0?, 0x7ef6efbba5b8?}}, 0xc00012bd40, 0xc0006a8808?)
	/home/runner/work/chezmoi/chezmoi/internal/chezmoi/sourcestate.go:1617 +0x5a
github.com/twpayne/chezmoi/v2/internal/chezmoi.(*SourceState).readExternalFile.func1()
	/home/runner/work/chezmoi/chezmoi/internal/chezmoi/sourcestate.go:2650 +0x2f
github.com/twpayne/chezmoi/v2/internal/chezmoi.(*lazyContents).Contents(0xc0004156d0)
	/home/runner/work/chezmoi/chezmoi/internal/chezmoi/lazy.go:77 +0x33
github.com/twpayne/chezmoi/v2/internal/chezmoi.(*TargetStateFile).EntryState(0xc0004311d0, 0x2)
	/home/runner/work/chezmoi/chezmoi/internal/chezmoi/targetstateentry.go:234 +0x26
github.com/twpayne/chezmoi/v2/internal/chezmoi.(*SourceState).Apply(0xc000380c00, {0x19ade90, 0xc0003ba838}, {0x19ae0a0, 0xc0003db320}, {0x19aaa58, 0xc0003ba298}, {0x0, 0x0}, {{0xc000461f20, ...}}, ...)
	/home/runner/work/chezmoi/chezmoi/internal/chezmoi/sourcestate.go:703 +0x1e3
github.com/twpayne/chezmoi/v2/internal/cmd.(*Config).applyArgs(0xc0006aa008, {0x19a49b0, 0x23b85c0}, {0x19ade90, 0xc0003ba838}, {0x0, 0x0}, {0x23b85c0, 0x0, 0x0}, ...)
	/home/runner/work/chezmoi/chezmoi/internal/cmd/config.go:653 +0x69f
github.com/twpayne/chezmoi/v2/internal/cmd.(*Config).runDumpCmd(0xc0006aa008, 0xc000779808, {0x23b85c0, 0x0, 0x0})
	/home/runner/work/chezmoi/chezmoi/internal/cmd/dumpcmd.go:40 +0x154
github.com/spf13/cobra.(*Command).execute(0xc000779808, {0x23b85c0, 0x0, 0x0})
	/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:983 +0xaca
github.com/spf13/cobra.(*Command).ExecuteC(0xc0001b9808)
	/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1115 +0x3ff
github.com/spf13/cobra.(*Command).Execute(...)
	/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.8.0/command.go:1039
github.com/twpayne/chezmoi/v2/internal/cmd.(*Config).execute(0xc0006dfde8?, {0xc000040050, 0x1, 0x1})
	/home/runner/work/chezmoi/chezmoi/internal/cmd/config.go:1227 +0x78
github.com/twpayne/chezmoi/v2/internal/cmd.runMain({{0x1990354, 0x6}, {0x19a15a0, 0x28}, {0x1995070, 0x14}, {0x1991318, 0xa}}, {0xc000040050, 0x1, ...})
	/home/runner/work/chezmoi/chezmoi/internal/cmd/cmd.go:270 +0x25c
github.com/twpayne/chezmoi/v2/internal/cmd.Main({{0x1990354, 0x6}, {0x19a15a0, 0x28}, {0x1995070, 0x14}, {0x1991318, 0xa}}, {0xc000040050, 0x1, ...})
	/home/runner/work/chezmoi/chezmoi/internal/cmd/cmd.go:106 +0xa5
main.main()
	/home/runner/work/chezmoi/chezmoi/main.go:24 +0xfb

To reproduce

I don't know what makes chezmoi break on this machine. It's not the only LXC container I use it in, and I don't think the setup is otherwise special. Go is v1.22.2.

Expected behavior

chezmoi dump should give me a variable dump

Output of command with the --verbose flag

Adding --verbose to the above command does not add any output.

Output of chezmoi doctor

$ chezmoi doctor
RESULT    CHECK                       MESSAGE
ok        version                     v2.48.0, commit c758a1c57fb6084631736a7dda5ac0aaeeffa946, built at 2024-04-26T20:38:57Z, built by goreleaser
ok        latest-version              v2.48.0
ok        os-arch                     linux/amd64 (Debian GNU/Linux)
ok        uname                       Linux armads 6.8.4-2-pve #1 SMP PREEMPT_DYNAMIC PMX 6.8.4-2 (2024-04-10T17:36Z) x86_64 GNU/Linux
ok        go-version                  go1.22.2 (gc)
ok        executable                  ~/bin/chezmoi
ok        upgrade-method              replace-executable
ok        config-file                 ~/.config/chezmoi/chezmoi.toml, last modified 2024-05-10T15:39:11Z
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        umask                       002
ok        cd-command                  found /bin/bash
ok        cd-args                     /bin/bash
info      diff-command                not set
ok        edit-command                found /usr/bin/vi
ok        edit-args                   /usr/bin/vi
ok        git-command                 found /usr/bin/git, version 2.43.0
ok        merge-command               found /usr/bin/vimdiff
ok        shell-command               found /bin/bash
ok        shell-args                  /bin/bash
info      age-command                 age not found in $PATH
ok        gpg-command                 found /usr/bin/gpg, version 2.2.40
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      rbw-command                 rbw not found in $PATH
info      vault-command               vault not found in $PATH
info      vlt-command                 vlt not found in $PATH
info      secret-command              not set

Thanks for reporting, this is #3662.

I think the root cause may have been having a file named .local/share/chezmoi/commitmsg.tmpl --- I was trying to override the commit message (something that is a bit underdocumented IMHO), and I noticed chezmoi would complain about the file (even if not hooked up via .config/chezmoi/chezmoi.toml), since it uses functions that are only available in the commit message templating context (targetRelPath).

It would be neat to have a quick howto on overriding the commit message --- all I wanted was the short hostname of the machine as a prefix to the subject line/first line of every commit.

I opened charmbracelet/bubbletea#1016 to report this. Closing this now as a dup of #3662 as I think this is a bug in a dependency, not in chezmoi.

If you have a way to reproduce the bug please add information to charmbracelet/bubbletea#1016. Thank you!