Skip to content

Local field on StringSliceFlag breaks the value parsing #2253

@ldez

Description

@ldez

My urfave/cli version is

v3.6.2

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.

Describe the bug

The flag option Local changes the behavior of StringSliceFlag.

To reproduce

package main

import (
	"context"
	"fmt"
	"log"
	"os"

	"github.com/urfave/cli/v3"
)

func main() {
	app := &cli.Command{
		Name: "foo",
		Action: func(ctx context.Context, cmd *cli.Command) error {
			fmt.Println(cmd.StringSlice("values"))

			return nil
		},
		Flags: []cli.Flag{
			&cli.StringSliceFlag{Name: "values", Local: true},
		},
	}

	err := app.Run(context.Background(), os.Args)
	if err != nil {
		log.Fatal("Error", err)
	}
}

Observed behavior

$ go run . --values a,b,c --values d --values e    
[e]

Expected behavior

$ go run . --values a,b,c --values d --values e
[a b c d e]

Additional context

Same problem with every slice based flags.

Want to fix this yourself?

Maybe

Run go version and paste its output here

go version go1.25.5 X:nodwarf5 linux/amd64

Run go env and paste its output here

Details
AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE='on'
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/home/ldez/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/ldez/.config/go/env'
GOEXE=''
GOEXPERIMENT='nodwarf5'
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build2592075677=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/home/ldez/sources/test/go.mod'
GOMODCACHE='/home/ldez/sources/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/ldez/sources/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/lib/go'
GOSUMDB='sum.golang.org'
GOTELEMETRY='on'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/lib/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.25.5 X:nodwarf5'
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