Fastly compute serve tries to write in C:/Windows and fails
Version
Fastly CLI version v10.12.1 (4aecc677) Built with go version go1.22.3 linux/amd64 (2024-06-13) Viceroy version: viceroy 0.9.7
What happened
Recently fastly compute serve starting crashing because it's trying to create a temporary directory in the Windows folder. Windows folder is not a writable directory, why is it trying to write there rather than one of the temporary folder or current folder?
command run: fastly compute serve --watch --auto-yes --verbose --watch-dir ./src --env local
👋🏻 Thanks for raising this issue.
Here is the function that is erroring...
https://github.com/fastly/cli/blob/c4e841e09964f36840807c9752137748b5c0eab1/pkg/commands/compute/build.go#L761-L799
...from what I can see the code is using Go's os.TempDir() to determine an appropriate 'temp' directory:
https://pkg.go.dev/os#TempDir
On Windows, it uses GetTempPath, returning the first non-empty value from %TMP%, %TEMP%, %USERPROFILE%, or the Windows directory.
It's unfortunate we can't rely on Go's built-in method for determining a temp directory.
I guess for Windows we'll likely have to switch to using the 'current' directory.
Any ideas why all those other variables would be empty causing it to fall back to the Windows directory? I don't use Windows, so I can't offer any theories.
Can't say, it's a normal windows 11 installation.
From: Cameron Walters (cee-dub) @.> Sent: Thursday, June 13, 2024 4:20:16 PM To: fastly/cli @.> Cc: Georges Chitiga @.>; Author @.> Subject: Re: [fastly/cli] Fastly compute serve tries to write in C:/Windows and fails (Issue #1227)
Any ideas why all those other variables would be empty causing it to fall back to the Windows directory? I don't use Windows, so I can't offer any theories.
— Reply to this email directly, view it on GitHubhttps://github.com/fastly/cli/issues/1227#issuecomment-2165816374, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAQBQD3LI6C5QSN4463UUCDZHGTCBAVCNFSM6AAAAABJHYJ6AWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNRVHAYTMMZXGQ. You are receiving this because you authored the thread.Message ID: @.***>
Relevant issue from Go itself: https://github.com/golang/go/issues/56899
@CGeorges Would you be able to paste the output of set in the CMD shell where you are running fastly compute serve? It would be helpful to see if any of the relevant environment variables are set, and what their values are.
Closing due to lack of response; if this is still an issue for you feel free to reopen it and provide the requested information.