flux2: flux fails to bootstrap a repo in a different Windows drive than the one in $env:TEMP

Describe the bug

When trying to bootstrap a new flux repository on Windows, if the target directory is in a different drive than $env:TEMP, flux will fail to bootstrap it, with the error below:

github.com/pellegrino/test-flux2-windows on ☁️  (eu-central-1)
❯ pwd

Path
----
D:\src\github.com\pellegrino\test-flux2-windows

github.com/pellegrino/test-flux2-windows on ☁️  (eu-central-1)
❯ flux bootstrap github --owner=pellegrino --repository=my-repo --branch=main --path .\clusters\dok8s --personal
► connecting to github.com
✔ repository cloned
✚ generating manifests
✗ generating install manifests failed: Rel: can't make C:\Users\VITORP~1\AppData\Local\Temp\flux-system445357215 relative to D:\src\github.com\pellegrino\test-flux2-windows

My $env:TEMP lives inside the C:. I haven’t tested changing it to a different drive to see if that has any impact.

❯ echo $env:TEMP
C:\Users\VITORP~1\AppData\Local\Temp

To Reproduce

Steps to reproduce the behavior:

  1. Create a new directory in a drive different than your $env:TEMP. I created mine on D:\
  2. Use flux bootstrap to initialize the repo. Flux should fail to install the manifests

Expected behavior

The new directory being bootstrap with the flux manifest files.

Additional context

  • Kubernetes version:
  • Git provider: github
  • Container registry provider:
  • OS: Windows 10 with Powershell

flux version

❯ flux --version
flux version 0.10.0

flux check

❯ flux check --pre
► checking prerequisites
✔ kubectl 1.19.7 >=1.18.0-0
✔ Kubernetes 1.20.2 >=1.16.0-0
✔ prerequisites checks passed

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Reactions: 12
  • Comments: 22 (6 by maintainers)

Most upvoted comments

Me to here. Have to copy our repos to disk C.

Please fix. Its been more than two months without any signs of an effort to fix this isssue.

Just wanted to add that I tried changing $env:TEMP to a directory on the other drive as @pellegrino hadn’t tested that, but the same error occurs.

I’m running Flux with the Terraform provider, so it’s inconvenient to move my repositories to a different drive, but I’ll do it until a solution is implemented.

As a workaround I run my terraform commands on WSL. It then uses the linux version of terraform but in most cases that works for me.

I just got that error too. I realized that it happened, when I ran the flux bootstrap from a different drive than drive C … After switching to drive C the execution worked!

I realized that the OP also used different drives, so hopefully this can provide a workaround until this is solved.

D:\Code\gitops>flux bootstrap github --components-extra=image-reflector-controller,image-automation-controller --hostname=some-repository --ssh-hostname=some-repository --owner=xyz--repository=gitops  --branch=master
► connecting to some-repository
► cloning branch "master" from Git repository "https://some-repository/xyz/gitops.git"
✔ cloned repository
► generating component manifests
✗ component manifest generation failed: Rel: can't make C:\Users\xyz\AppData\Local\Temp\flux-manifests-3183109114 relative to D:\Code\gitops

D:\Code\gitops>c:

C:\Users\xyz>flux bootstrap github --components-extra=image-reflector-controller,image-automation-controller --hostname=some-repository --ssh-hostname=some-repository --owner=xyz --repository=gitops  --branch=master
► connecting to some-repository
► cloning branch "master" from Git repository "https://some-repository/xyz/gitops.git"
✔ cloned repository
► generating component manifests
✔ generated component manifests
✔ committed sync manifests to "master" ("464255e37c49724b85c07bef23408d6c91654bd5")
► pushing component manifests to "https://some-repository/xyz/gitops.git"
► installing components in "flux-system" namespace
✔ installed components
✔ reconciled components
► determining if source secret "flux-system/flux-system" exists
► generating source secret
...

I am a proud windows user and hopefully well enough familiar with go - I will try if I can setup a dev env on the weekend, and take a look.

@simongottschlag

I think the error comes from here: https://github.com/fluxcd/flux2/blob/main/pkg/manifestgen/manifest.go#L40-L43 Most likely related to securejoin: https://github.com/cyphar/filepath-securejoin/blob/master/join.go

I’m not yet fluent in Flux source code, but I suspect the issue leaks from here https://github.com/fluxcd/flux2/blob/5eb43e45664498ef7abde14a942f3771cc987049/pkg/manifestgen/kustomization/kustomization.go#L174-L182 and/or here https://github.com/fluxcd/flux2/blob/5eb43e45664498ef7abde14a942f3771cc987049/pkg/manifestgen/kustomization/kustomization.go#L107 but, I guess, the latter is directly related to the former.

All that seems related to the Kustomize bug https://github.com/kubernetes-sigs/kustomize/issues/2789 from 2020 which was due to bug in its dependency go-getter.

Good news is that in 2021 Kustomize dropped use of go-getter https://github.com/kubernetes-sigs/kustomize/pull/3586 So, perhaps the whole workaround in line kustomization.go:177 above with turning absolute paths to relative paths is no longer needed and once removed, this bug in hand will no longer occur.

can't make C:\Users\... relative to D:\src\github.com\...

You don’t really need to move the source code the the C:/ Just use CD to change the current folder where you execute the fux cli

I confirm the problem still exists in Flux 0.41.2

I’m simply learning Flux and trying the podinfo deployment as tutorial in Git Bash session:

$ flux install --namespace=flux-system --network-policy=false --components=source-controller,helm-controller
✚ generating manifests
✗ install failed: Rel: can't make C:\Users\mateuszl\AppData\Local\Temp\flux-system2569008128 relative to F:\tmp

In case other confused Flux newbies arrive here, switching to WSL session works around the problem easily, without moving files away from F: or re-installing Flux, just go inside /mnt/f/tmp and re-run the command above. Thanks @bravecobra