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

"flag redefined: cpuprofile" with sha1cd v0.3.1, avo v0.6.0 #893

Closed
MarcWort opened this issue Jan 16, 2025 · 4 comments · Fixed by #895
Closed

"flag redefined: cpuprofile" with sha1cd v0.3.1, avo v0.6.0 #893

MarcWort opened this issue Jan 16, 2025 · 4 comments · Fixed by #895
Assignees

Comments

@MarcWort
Copy link
Contributor

Hi, you are using github.com/pjbgf/sha1cd currently in verion 0.3.0. If upgraded to version 0.3.1 it also updates github.com/mmcloughlin/avo to v0.6.0, which defines the flag "cpuprofile" here also defined here:

cpuProfile := flag.String("cpuprofile", "", "write cpu profile to `file`")

Its probably a good idea to create some own FlagSet (NewFlagSet) or do some workaround to keep zoekt updatable in the future.

Maybe it would even be possible to remove the old workaround "cpu_profile" by doing it right this time and consolidate the cpuprofile argument.

cpuProfile := flag.String("cpu_profile", "", "write cpu profile to file")

Steps to reproduce

go get -u ./... && go run ./cmd/zoekt-git-index/

Output:

/tmp/go-build2071650996/b001/exe/zoekt-git-index flag redefined: cpuprofile
panic: /tmp/go-build2071650996/b001/exe/zoekt-git-index flag redefined: cpuprofile

goroutine 1 [running]:
flag.(*FlagSet).Var(0xc0000f6150, {0x13140e0, 0xc0002f70c0}, {0x10b0cbb, 0xa}, {0x11935ee, 0x1b})
        /opt/go/src/flag/flag.go:1028 +0x37d
flag.(*FlagSet).StringVar(...)
        /opt/go/src/flag/flag.go:879
flag.(*FlagSet).String(0xc0000f6150, {0x10b0cbb, 0xa}, {0x0, 0x0}, {0x11935ee, 0x1b})
        /opt/go/src/flag/flag.go:892 +0xa5
flag.String(...)
        /opt/go/src/flag/flag.go:899
main.run()
        /home/user/github/zoekt/cmd/zoekt-git-index/main.go:49 +0x25a
main.main()
        /home/user/github/zoekt/cmd/zoekt-git-index/main.go:146 +0x13
Copy link

linear bot commented Jan 16, 2025

@MarcWort
Copy link
Contributor Author

somewhat related: #756

@keegancsmith
Copy link
Member

Thanks for the very detailed report! I'll tackle this now.

Doing a reasonably large refactor due to a misbehaving transitive dependency I'm not so keen on, especially since this is the first time I have run into this in this project. If it happens again I'll happily do that. For now I'll just rename the flag to cpu_profile to be consistent with most of our commands.

@keegancsmith
Copy link
Member

Following up here, the maintainer of avo sent a PR to sha1cd to remove the dependency on avo on the root go module and that just landed. So now the extra flags being registered is gone since #898 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants