carapace-sh / carapace

command argument completion generator for spf13/cobra
https://carapace.sh
Apache License 2.0
321 stars 8 forks source link

Log is spammed with `failed to register flag completion func` #793

Closed rsteube closed 1 year ago

rsteube commented 1 year ago

Current Behavior

Log is full with failed to register flag completion func: RegisterFlagCompletionFunc: flag 'v' already registered. Seems re-registering is happening somehow.

Expected Behavior

Prevent or suppress messages (if behaviour is ok).

Steps To Reproduce

  1. enable logging
  2. invoke completion

Version

No response

OS

Shell

Anything else?

No response

rsteube commented 1 year ago

First time to run into concurrent map writes during completion. Probably should finally add the missing mutexes to storage as well when fixing this.

esh ❯ carapace go<TAB>
fatal error: concurrent map writes

goroutine 9 [running]:
github.com/rsteube/carapace._storage.get(...)
    /home/rsteube/go/pkg/mod/github.com/rsteube/carapace@v0.38.2/storage.go:32
github.com/rsteube/carapace.Carapace.PositionalAnyCompletion(...)
    /home/rsteube/go/pkg/mod/github.com/rsteube/carapace@v0.38.2/carapace.go:61
github.com/rsteube/carapace.addCompletionCommand(0xc0004b0000)
    /home/rsteube/go/pkg/mod/github.com/rsteube/carapace@v0.38.2/command.go:104 +0x8a6
github.com/rsteube/carapace.Gen(0xc0004b0000)
    /home/rsteube/go/pkg/mod/github.com/rsteube/carapace@v0.38.2/carapace.go:19 +0x1e
github.com/rsteube/carapace.initHelpCompletion(0xc0022f1800)
    /home/rsteube/go/pkg/mod/github.com/rsteube/carapace@v0.38.2/internalActions.go:157 +0x11a
github.com/rsteube/carapace.complete(0xc000132000?, {0xc0004ac0f0, 0x3, 0x3})
    /home/rsteube/go/pkg/mod/github.com/rsteube/carapace@v0.38.2/complete.go:16 +0x69
github.com/rsteube/carapace.addCompletionCommand.func1(0xc0022f1b00, {0xc0004ac0f0?, 0x3, 0x3})
    /home/rsteube/go/pkg/mod/github.com/rsteube/carapace@v0.38.2/command.go:35 +0x129
github.com/spf13/cobra.(*Command).execute(0xc0022f1b00, {0xc0004ac0f0, 0x3, 0x3})
    /home/rsteube/go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:944 +0x847
github.com/spf13/cobra.(*Command).ExecuteC(0xc0022f1800)
    /home/rsteube/go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:1068 +0x3bd
github.com/spf13/cobra.(*Command).Execute(...)
    /home/rsteube/go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:992
github.com/rsteube/carapace.ActionExecute.func1({{0x7ffec61a44b0, 0x2}, {0xc002488710, 0x0, 0x1}, {0x1ba6ca0, 0x0, 0x0}, {0xc002461000, 0x3e, ...})
    /home/rsteube/go/pkg/mod/github.com/rsteube/carapace@v0.38.2/defaultActions.go:125 +0x350
github.com/rsteube/carapace.Action.Invoke({{{0x0}, {{0x0, 0x0}}, {0x0, 0x0}}, {0x0, 0x0, 0x0}, 0xc0027d5590}, {{0x7ffec61a44b0, ...}, ...})
    /home/rsteube/go/pkg/mod/github.com/rsteube/carapace@v0.38.2/action.go:68 +0x222
github.com/rsteube/carapace.batch.Invoke.func1()
    /home/rsteube/go/pkg/mod/github.com/rsteube/carapace@v0.38.2/batch.go:24 +0xaa
github.com/rsteube/carapace.parallelize.func1(0x0?)
    /home/rsteube/go/pkg/mod/github.com/rsteube/carapace@v0.38.2/batch.go:64 +0x57
created by github.com/rsteube/carapace.parallelize
    /home/rsteube/go/pkg/mod/github.com/rsteube/carapace@v0.38.2/batch.go:62 +0x85