Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chezmoi panics when using with --exclude scripts #1163

Closed
breml opened this issue Apr 17, 2021 · 1 comment · Fixed by #1165
Closed

chezmoi panics when using with --exclude scripts #1163

breml opened this issue Apr 17, 2021 · 1 comment · Fixed by #1165
Labels
bug Something isn't working

Comments

@breml
Copy link

breml commented Apr 17, 2021

Describe the bug

With version v2.0.10, which includes the fix for #1083, the command chezmoi diff --exclude scripts panics.

For test purposes I removed the following setting from my config, but it did not change the outcome:

diff:
    exclude: ["scripts"]

To reproduce

$ chezmoi diff --exclude scripts
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x86c47b]

goroutine 1 [running]:
github.com/twpayne/chezmoi/v2/internal/chezmoi.(*EntryTypeSet).SetSlice(0x0, 0xc0001184f0, 0x1, 0x1, 0x0, 0x0)
        /home/runner/work/chezmoi/chezmoi/internal/chezmoi/entrytypeset.go:145 +0x7b
github.com/twpayne/chezmoi/v2/internal/chezmoi.(*EntryTypeSet).Set(0x0, 0x7ffeead05704, 0x7, 0x7, 0xc0002b82f8)
        /home/runner/work/chezmoi/chezmoi/internal/chezmoi/entrytypeset.go:117 +0x9e
github.com/spf13/pflag.(*FlagSet).Set(0xc000844600, 0x1033711, 0x7, 0x7ffeead05704, 0x7, 0x7ffeead056fc, 0xc0002b8270)
        /home/runner/go/pkg/mod/github.com/spf13/pflag@v1.0.5/flag.go:463 +0xe2
github.com/spf13/pflag.(*FlagSet).Parse.func1(0xc00068fea0, 0x7ffeead05704, 0x7, 0x7, 0xc0002b82f8)
        /home/runner/go/pkg/mod/github.com/spf13/pflag@v1.0.5/flag.go:1138 +0x54
github.com/spf13/pflag.(*FlagSet).parseLongArg(0xc000844600, 0x7ffeead056fa, 0x9, 0xc000261090, 0x1, 0x1, 0xc00039bb80, 0x20, 0x7fdfacd68108, 0x20, ...)
        /home/runner/go/pkg/mod/github.com/spf13/pflag@v1.0.5/flag.go:1000 +0x295
github.com/spf13/pflag.(*FlagSet).parseArgs(0xc000844600, 0xc000261090, 0x1, 0x2, 0xc00039bb80, 0x572a78, 0xc000845d00)
        /home/runner/go/pkg/mod/github.com/spf13/pflag@v1.0.5/flag.go:1108 +0x46e
github.com/spf13/pflag.(*FlagSet).Parse(0xc000844600, 0xc000261080, 0x2, 0x2, 0x0, 0xc00092f9e0)
        /home/runner/go/pkg/mod/github.com/spf13/pflag@v1.0.5/flag.go:1141 +0x13d
github.com/spf13/cobra.(*Command).ParseFlags(0xc0005ae280, 0xc000261080, 0x2, 0x2, 0xc000261080, 0xc00039bcb8)
        /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:1625 +0xbf
github.com/spf13/cobra.(*Command).execute(0xc0005ae280, 0xc000261080, 0x2, 0x2, 0xc0005ae280, 0xc000261080)
        /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:779 +0xae
github.com/spf13/cobra.(*Command).ExecuteC(0xc000690c80, 0xc000690c80, 0x0, 0x0)
        /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:960 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
        /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:897
github.com/twpayne/chezmoi/v2/cmd.(*Config).execute(0xc0002ee800, 0xc00012a010, 0x3, 0x3, 0x0, 0x0)
        /home/runner/work/chezmoi/chezmoi/cmd/config.go:809 +0x7d
github.com/twpayne/chezmoi/v2/cmd.runMain(0x1567c54, 0x6, 0x1587fc0, 0x28, 0x156ae20, 0x14, 0x1568a38, 0xa, 0xc00012a010, 0x3, ...)
        /home/runner/work/chezmoi/chezmoi/cmd/cmd.go:245 +0xe7
github.com/twpayne/chezmoi/v2/cmd.Main(0x1567c54, 0x6, 0x1587fc0, 0x28, 0x156ae20, 0x14, 0x1568a38, 0xa, 0xc00012a010, 0x3, ...)
        /home/runner/work/chezmoi/chezmoi/cmd/cmd.go:85 +0x8e
main.main()
        /home/runner/work/chezmoi/chezmoi/main.go:17 +0x131

Expected behavior

--exclude scripts should work the same as before v2.0.10.

Output of command with --verbose

Same output as without --versbose

Output of chezmoi doctor

Not relevant, everything is ok.

@breml breml changed the title chezmoi panic when using --exclude scripts chezmoi panics when using with --exclude scripts Apr 17, 2021
@twpayne twpayne added the bug Something isn't working label Apr 17, 2021
@lcrockett
Copy link

Can confirm the bug, however only when specifying --exclude scripts on the CLI. It works well when having the exclusion configured in the chezmoi.toml configuration file and then running chezmoi diff without any arguments. See snippet below for chezmoi.toml content:

[diff]
    exclude = ["scripts"]

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants