flux2 icon indicating copy to clipboard operation
flux2 copied to clipboard

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

Open pellegrino opened this issue 3 years ago • 12 comments

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

pellegrino avatar Mar 25 '21 05:03 pellegrino

Hi!

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

Not sure how it should be handled though.

Ping @stefanprodan @phillebaba

simongottschlag avatar Mar 25 '21 23:03 simongottschlag

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

dzmitry-lahoda avatar Sep 27 '21 06:09 dzmitry-lahoda

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
...

domoran avatar Mar 18 '22 16:03 domoran

I can confirm moving to c resolves the issue

Saoirse-Derry avatar May 14 '22 15:05 Saoirse-Derry

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

thesn10 avatar May 28 '22 12:05 thesn10

Yes, it works from drive C

majid-rafei avatar Jun 07 '22 12:06 majid-rafei

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.

kitforbes avatar Jun 23 '22 17:06 kitforbes

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.

bravecobra avatar Aug 19 '22 02:08 bravecobra

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

mloskot avatar Apr 04 '23 13:04 mloskot

/assign

basit9958 avatar Apr 15 '23 20:04 basit9958

It seems that the root path provided to SecureJoinVFS is on a different drive than the one specified in $env:TEMP, which causes an issue when resolving the symbolic links. To resolve this issue, you may want to ensure that the root path provided to SecureJoinVFS is on the same drive as the one specified in $env:TEMP.

basit9958 avatar Apr 15 '23 20:04 basit9958

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

ngothiensinh avatar Feb 07 '24 03:02 ngothiensinh