EDITOR environment variable is needed(?)
rcassani opened this issue · 3 comments
I made the install with: go install github.com/mbrt/gmailctl/cmd/gmailctl@latest
,
configured xdg-mime to use my editor, through modifying ~/.config/mimeapps.list
,
and followed instructions to set up the Gmail API.
However at running gmailctl edit
I get this error:
panic: errors: target must be a non-nil pointer
goroutine 1 [running]:
errors.As({0xc96180, 0xc000138ee0}, {0xb3ff60, 0x0?})
/usr/lib/go/src/errors/wrap.go:85 +0x3f2
github.com/mbrt/gmailctl/cmd/gmailctl/cmd.spawnEditor({0xc00014aea0, 0x20})
/home/rcassani/go/pkg/mod/github.com/mbrt/gmailctl@v0.10.2/cmd/gmailctl/cmd/edit_cmd.go:181 +0x2b3
github.com/mbrt/gmailctl/cmd/gmailctl/cmd.edit({0xc000128870, 0x27}, 0x0?)
/home/rcassani/go/pkg/mod/github.com/mbrt/gmailctl@v0.10.2/cmd/gmailctl/cmd/edit_cmd.go:90 +0x19f
github.com/mbrt/gmailctl/cmd/gmailctl/cmd.glob..func5(0x12707e0?, {0xb68d4f?, 0x0?, 0x0?})
/home/rcassani/go/pkg/mod/github.com/mbrt/gmailctl@v0.10.2/cmd/gmailctl/cmd/edit_cmd.go:60 +0x55
github.com/spf13/cobra.(*Command).execute(0x12707e0, {0x12b8708, 0x0, 0x0})
/home/rcassani/go/pkg/mod/github.com/spf13/cobra@v1.4.0/command.go:860 +0x663
github.com/spf13/cobra.(*Command).ExecuteC(0x1270f60)
/home/rcassani/go/pkg/mod/github.com/spf13/cobra@v1.4.0/command.go:974 +0x3b4
github.com/spf13/cobra.(*Command).Execute(...)
/home/rcassani/go/pkg/mod/github.com/spf13/cobra@v1.4.0/command.go:902
github.com/mbrt/gmailctl/cmd/gmailctl/cmd.Execute()
/home/rcassani/go/pkg/mod/github.com/mbrt/gmailctl@v0.10.2/cmd/gmailctl/cmd/root_cmd.go:26 +0x25
main.main()
/home/rcassani/go/pkg/mod/github.com/mbrt/gmailctl@v0.10.2/cmd/gmailctl/main.go:10 +0x51
Taking a look to the code, I noticed that by setting the EDITOR
variable, I can avoid that error.
Is this expected?
Does EDITOR
overrides the editor specified in mimeapps.list
?
gmailctl doesn't look at mimeapps.list
in any way. The logic is pretty easy: if $EDITOR
is specified, it gives that priority, otherwise it just goes through a predefined list of editors to try:
gmailctl/cmd/gmailctl/cmd/edit_cmd.go
Lines 165 to 167 in 5a63847
If all of them fail, it returns no suitable editor found
.
I don't understand how you can have that crash honestly.
Thanks for the info, I found the bug, it was the second argument in errors.As
.
Fix submitted as PR #251
Ow that's a good catch. How did it work until today I wonder? https://go.dev/play/p/j4AZfbsZx4R