Skip to content

Cannot provide absolute file paths to --set-files flag on Windows OS #9537

Closed

Description

@gsquared94

Run on PowerShell:

PS C:\Users\gaura\code\skaffoldHelmMultiRepo> helm install --dry-run stable/mariadb --set-file foo.bar=C:\Users\gaghosh\foo --generate-name
Error: failed parsing --set-file data: open C:Usersgaghoshfoo: The system cannot find the file specified.

Can also be reproduced by modifying the TestParseIntoFile unit test, to:

func TestParseIntoFile(t *testing.T) {
	got := map[string]interface{}{}
	input := `name1=C:\foo\path1`
	expect := map[string]interface{}{
		"name1": "value1",
	}
	rs2v := func(rs []rune) (interface{}, error) {
		v := string(rs)
		if v != `C:\foo\path1` {
			t.Errorf("%s: runesToVal: Expected value path1, got %s", input, v)
			return "", nil
		}
		return "value1", nil
	}

	if err := ParseIntoFile(input, got, rs2v); err != nil {
		t.Fatal(err)
	}

	y1, err := yaml.Marshal(expect)
	if err != nil {
		t.Fatal(err)
	}
	y2, err := yaml.Marshal(got)
	if err != nil {
		t.Fatalf("Error serializing parsed value: %s", err)
	}

	if string(y1) != string(y2) {
		t.Errorf("%s: Expected:\n%s\nGot:\n%s", input, y1, y2)
	}
}

Test output:

go test -timeout 30s -run ^TestParseIntoFile$ helm.sh/helm/v3/pkg/strvals
--- FAIL: TestParseIntoFile (0.00s)
    parser_test.go:612: name1=C:\foo\path1: runesToVal: Expected value path1, got C:foopath1
    parser_test.go:632: name1=C:\foo\path1: Expected:
        name1: value1
        
        Got:
        name1: ""
FAIL
FAIL    helm.sh/helm/v3/pkg/strvals     0.002s
FAIL

However it works with \\ filepath separators, like: C:\\Users\\gaghosh\\foo. Is this the expected behavior or a bug?


Output of helm version:

version.BuildInfo{Version:"v3.2.4", GitCommit:"0ad800ef43d3b826f31a5ad8dfbb4fe05d143688", GitTreeState:"clean", GoVersion:"go1.13.12"}

Output of kubectl version:

Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.0", GitCommit:"9e991415386e4cf155a24b1da15becaa390438d8", GitTreeState:"clean", BuildDate:"2020-03-25T14:58:59Z", GoVersion:"go1.13.8", Compiler:"gc", Platform:"windows/amd64"}
Server Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.4", GitCommit:"d360454c9bcd1634cf4cc52d1867af5491dc9c5f", GitTreeState:"clean", BuildDate:"2020-11-11T13:09:17Z", GoVersion:"go1.15.2", Compiler:"gc", Platform:"linux/amd64"}

Cloud Provider/Platform (AKS, GKE, Minikube etc.):

minikube

Activity

  1. mattfarina commented on Mar 25, 2021

    @mattfarina
    Collaborator

    The \ character is one that usually needs to be escaped. There are a handful of characters that need to be escaped and that's one of them. What happens when the value is in quotes? That's what's usually recommended for this case to avoid needing to escape these characters.

  2. gsquared94 commented on Apr 1, 2021

    @gsquared94
    Author

    Using quotes in the argument also doesn't work:

    PS C:\Users\gaura\code\skaffoldHelmMultiRepo> helm install --dry-run stable/mariadb --set-file foo.bar="C:\Users\gaghosh\foo" --generate-name
    Error: failed parsing --set-file data: open C:Usersgaghoshfoo: The system cannot find the file specified.
    PS C:\Users\gaura\code\skaffoldHelmMultiRepo> helm install --dry-run stable/mariadb --set-file foo.bar='C:\Users\gaghosh\foo' --generate-name
    Error: failed parsing --set-file data: open C:Usersgaghoshfoo: The system cannot find the file specified.
    PS C:\Users\gaura\code\skaffoldHelmMultiRepo> helm install --dry-run stable/mariadb --set-file "foo.bar=C:\Users\gaghosh\foo" --generate-name
    Error: failed parsing --set-file data: open C:Usersgaghoshfoo: The system cannot find the file specified.
    PS C:\Users\gaura\code\skaffoldHelmMultiRepo> helm install --dry-run stable/mariadb --set-file 'foo.bar=C:\Users\gaghosh\foo' --generate-name
    Error: failed parsing --set-file data: open C:Usersgaghoshfoo: The system cannot find the file specified.
    

    For comparison the kubectl command doesn't need this (works with both \ and \\):

    PS C:\> kubectl config current-context
    minikube
    PS C:\> kubectl apply -f C:\Users\gaura\code\nginx-app.yaml
    service/my-nginx-svc created
    deployment.apps/my-nginx created
    PS C:\> kubectl apply -f C:\\Users\\gaura\\code\\nginx-app.yaml
    service/my-nginx-svc unchanged
    deployment.apps/my-nginx unchanged
    
  3. added
    bug
    and removed on Apr 2, 2021
  4. github-actions commented on Jul 2, 2021

    @github-actions

    This issue has been marked as stale because it has been open for 90 days with no activity. This thread will be automatically closed in 30 days if no further activity occurs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Stalebug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions