Skip to content

--verbose flag gets interpreted as "print version and exit" #2229

@tcard

Description

@tcard

My urfave/cli version is

3.6.1

Checklist

  • Are you running the latest v3 release? The list of releases is here.
  • Did you check the manual for your release? The v3 manual is here
  • Did you perform a search about this problem? Here's the GitHub guide about searching.

Dependency Management

  • My project is using go modules.
  • My project is using vendoring.
  • My project is automatically downloading the latest version.

Describe the bug

After the upgrade from v2 to v3, our command starting always printing the version and exiting when passed --verbose.

We narrowed it down to the way --verbose is defined:

&cli.BoolFlag{
	Name:    "verbose",
	Aliases: []string{"v"},
},

It looks like the v alias conflicts with the default version flag.

To reproduce

  • Define a boolean flag that has v as alias.
  • Call the command, setting the flag to true.

See in Go playground.

Observed behavior

Command prints version and exits.

Expected behavior

One of:

  • The clash on alias v is detected and the library returns an error or panics.
  • The custom flag definition completely replaces default version flag.

Additional context

Want to fix this yourself?

I'm open to it!

Run go version and paste its output here

go version go1.25.4 darwin/arm64

Run go env and paste its output here

AR='ar'
CC='clang'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='clang++'
GCCGO='gccgo'
GO111MODULE=''
GOARCH='arm64'
GOARM64='v8.0'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/Users/tcard/Library/Caches/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/Users/tcard/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/l3/h28qjr993sl4y2cgmkl06v980000gn/T/go-build751984059=/tmp/go-build -gno-record-gcc-switches -fno-common'
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/tcard/go/pkg/mod'
GOOS='darwin'
GOPATH='/Users/tcard/go'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/Users/tcard/go/pkg/mod/golang.org/[email protected]'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/tcard/Library/Application Support/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/Users/tcard/go/pkg/mod/golang.org/[email protected]/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.25.4'
GOWORK=''
PKG_CONFIG='pkg-config'

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/v3relates to / is being considered for v3kind/bugdescribes or fixes a bugstatus/triagemaintainers still need to look into this

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions