This is a very newbie question, so, my apologies, but I am at my wit’s end trying to figure this out.
I’m using stack version 3.1.1 for windows and, try as I might, I cannot avoid getting the following error:
Already downloaded msys2-20240727.
Already downloaded 7z.dll.
Already downloaded 7z.exe.
C:\stack-tmp-ee8f5b455efe402d: CreateDirectory “\\?\C:\stack-tmp-ee8f5b455efe402d”: permission denied (Access is denied.)
I believe I’ve set appropriate values for TMP which my reading said was where the temp directory should be. So, if anyone has any help for me, I’d be grateful.
Is there a way to get stack to print out the environment variables it’s using?
Am I setting the wrong environment variables.
It looks like Stack is trying to create a temporary directory in a location where it does not have permission. I’ll check Stack’s code, but I am surprised that it is trying to do that in the root of the C:\ drive.
Having looked at Stack’s code, Stack should be creating that temporary directory in ~the configured ‘local programs’ directory.~ [EDIT1: That’s not correct; see below.] That is configured in a Stack configuration file using the local-programs-path key: Non-project specific configuration - The Haskell Tool Stack
Command stack path --programs to see what Stack understands to be the configured location. See: path - The Haskell Tool Stack
EDIT1: Strike that. Having looked at Stack’s verbose output, it seems to be doing something different … update to follow.
EDIT2: Correction: Stack.Setup.withUnpackedTarball7z has (extract):
withRunInIO $ \run ->
-- We use a temporary directory in the same drive as that of 'destDir' to
-- reduce the risk of a filepath length of more than 260 characters, which can
-- be problematic for 7-Zip even if Long Filepaths are enabled on Windows. We
-- do not use the system temporary directory as it may be on a different
-- drive.
withTempDir destDrive tmpName $ \tmpDir ->
run $ do
liftIO $ ignoringAbsence (removeDirRecur destDir)
run7z tmpDir archiveFile
...
Stack is trying to create a temporary directory in C:\ because of an understood limitation with 7-Zip.
EDIT4: Since September 2022, new installations of Stack will have used 7-Zip 22.01.
EDIT5: I don’t know if it is yet safe (in mid-2025) to assume that Stack (and, consequently, 7-Zip) is being used on a Windows system with long file paths enabled.
The added documentation is useful but not helpful. You’re correct that I typically run as a regular user and not as administrator - it’s a safety policy that makes a lot of sense to me.
Is there a way to enable long file paths? If not, is my only solution to run as admin?
So this is very naive - are there instructions on how to build stack? In the past I have just downloaded a Windows binary! Or is there a link to a new binary using your modification?
I’ve added links above to binary distributions (in an archive file).
Each time Stack’s integration-tests GitHub workflow completes, as part of the CI at its GitHub repository, it creates binary distributions as an artefact.
Sorry for being slow to follow up. I tried the stack upgrade command both as administrator and as a regular user, in both cases I ended up with “git: readCreateProcess: does not exist (No such file or directory)”
Both links lead me to the git version of 404 Not found otherwise I’d download and install a version
I aim to release new versions of Stack around calendar quarter ends, unless nothing much has happened. So, this should be available in a released version of Stack in about a month’s time.