Problems using Stack in a MSYS2 shell

@drbean, picking up your question here:

Stack comes with an MSYS2 environment on Windows, so I’ll use that to experiment rather than creating a duplicate environment on my machine. On my machine, that MSYS2 is located at D:\sr\programs\x86_64-windows\msys2-20240727 - that is because I have set STACK_ROOT to be D:\sr and, in the Stack root, in config.yaml, I have set:

local-programs-path: D:\sr\programs

So, I open a MSYS2 shell by double-clicking on:

D:\sr\programs\x86_64-windows\msys2-20240727\msys2_shell.cmd

In that shell, Stack is not on the PATH, so I’ll use the long form to run it:

$ /c/Users/mike/AppData/Roaming/local/bin/stack --version

Now, I can command:

$ /c/Users/mike/AppData/Roaming/local/bin/stack build turtle

and the command works as expected. As I am outside of any Stack project’s directory, the package is built against the stack.yaml ‘of last resort’ that is located in the global-project directory of the Stack root. On my machine that specifies:

packages: []
snapshot: lts-24.37

Here, I don’t use stack install turtle because the turtle package does not have an executable stanza, so specifying stack build --copy-bins (which is what stack install is a synonym for) has no special effect - there are no executable binary distributions to copy after the package has been built.

So, why does my experience differ from yours? Perhaps the clue is in your message:

C:\ghcup\bin\ghc-9.14.1.exe ... -o C:\Users\drbean\AppData\Roaming\stack\setup-exe-cache\x86_64-windows\
tmp-Cabal-simple_O_vy6YIf_3.16.0.0_ghc-9.14.1.exe

This is (a) using GHC 9.14.1 (for which there is no Stackage snapshot) and (b) a version of GHC supplied by GHCup. I don’t use, or need to use, GHCup to manage GHC versions on Windows - I use Stack to manage GHC versions directly.

If I try to build against GHC 9.14.1 (by specifying a GHC 9.12.4 snapshot and overriding the compiler version in that snapshot), I get:

$ /c/Users/mike/AppData/Roaming/local/bin/stack --snapshot nightly-2026-04-16 --compiler ghc-9.14.1 build turtle

Warning: Ignoring tagged's bounds on template-haskell (>=2.11 && <2.24) and using
         template-haskell-2.24.0.0.
         Reason: trusting snapshot over Cabal file dependency information.

Error: [S-4804]
       Stack failed to construct a build plan.

       While constructing the build plan, Stack encountered the following errors. The 'Stack
       configuration' refers to the set of package versions specified by the snapshot (after any
       dropped packages, or pruned GHC boot packages; if a boot package is replaced, Stack prunes
       all other such packages that depend on it) and any extra-deps:

       In the dependencies for turtle-1.6.2:
         * containers must match >=0.5.0.0 && <0.8, but containers-0.8 is in the Stack configuration
           (latest matching version is 0.7).
         * optparse-applicative must match >=0.18 && <0.19, but optparse-applicative-0.19.0.0 is in
           the Stack configuration (latest matching version is 0.18.1.0).
         * time must match <1.15, but time-1.15 is in the Stack configuration (latest matching
           version is 1.14).
       The above is/are needed since turtle is a build target.

       Some different approaches to resolving some or all of this:

         * To ignore all version constraints and build anyway, pass --allow-newer, or, in
           D:\sr\config.yaml (global configuration), set allow-newer: true.

         * To ignore certain version constraints and build anyway, also add these package names
           under allow-newer-deps: turtle.

         * Recommended action: try adding the following to your extra-deps in
           D:\sr\global-project\stack.yaml (project-level configuration):

           - containers-0.7@sha256:e9b5fdcc609159410d408c47e0be13663bb0b4a42a5183b52aa0ac9c99e1dfec,2668
           - optparse-applicative-0.18.1.0@sha256:f30973861ac7e7ebff05ff8c7c3d1e4d283a1f3850e1cc14106b0693ec1b6d82,5289
           - time-1.14@sha256:918455e07f347049c2169a43169aca77de7a2c97e33aca0b476aabcd8a79798d,6989

So, I’ll need a more complex package version set in stack.yaml before turtle-1.6.2 will build. I can build a local copy of turtle with GHC 9.14.1 in a MSYS2 shell with:

$ /c/Users/mike/AppData/Roaming/local/bin/stack unpack turtle
$ cd turtle-1.6.2
$ /c/Users/mike/AppData/Roaming/local/bin/stack build

and

# stack.yaml
snapshot: nightly-2026-04-16
compiler: ghc-9.14.1

extra-deps:
- binary-0.8.9.3@sha256:8b03c7fd5a7f6803280fba87e38d534beb1dc92fec975de5bd36200633996ef2,6576
- containers-0.7@sha256:e9b5fdcc609159410d408c47e0be13663bb0b4a42a5183b52aa0ac9c99e1dfec,2668
- directory-1.3.10.1@sha256:bf029d8163ccae567cc6a5aa8f654016f58dfc066d15f8a8f7c74b8ca855562c,3174
- file-io-0.1.6@sha256:5e3466f15993e499db47d79d09c519d6d37c143cfe94fb46dd218bf2f6f3fd39,3550
- filepath-1.4.301.0@sha256:2c5d05f98759938db45757016ec406ed2c6021cd9018a53fedb76b9d5a8239ea,6128
- optparse-applicative-0.18.1.0@sha256:f30973861ac7e7ebff05ff8c7c3d1e4d283a1f3850e1cc14106b0693ec1b6d82,5289
- process-1.6.27.0@sha256:0512ed17e7e312a6412859abcb37a7bcc81b94cbb797a1ba2a8c78a5d3055d32,2947
- text-2.1.4@sha256:32823fd40b02db9b4ef4c527c9c3e6c1dcd365b8a79521f9d78d2c0a0a8d64f1,11602
- time-1.14@sha256:918455e07f347049c2169a43169aca77de7a2c97e33aca0b476aabcd8a79798d,6989
- Win32-2.14.2.1@sha256:7c68fc9d937c6e4c590472e9dd06d7e336338e01a5f2918ee9cf75c28871badd,5875

What version of stack was that?

I tried to replicate that build following the same procedure, the only difference being the ghcup-managed stack, versions 3.9.3, at some point downgraded to 3.7.1, and the independently-installed msys2 at c:\msys64.

But again they failed with the same permission denied on c:\windows\ghc5084_0, etc at first with msys2’s TMP=/tmp and then with the reinstated windows c:\Users\drbean\AppData\Local\Temp.

Interestingly, in that tmp dir, there are 3 files from 2 days ago,

-rwxr-xr-x 1 drbean なし 78336 Apr 16 16:08 AppData/Local/Temp/ghc11D2.exe
-rwxr-xr-x 1 drbean なし 78336 Apr 16 16:08 AppData/Local/Temp/ghc3E12.exe
-rwxr-xr-x 1 drbean なし 81408 Apr 16 18:23 AppData/Local/Temp/ghcD835.exe

Then I tried creating a shortcut on the desktop for stack’s programs/x86_64-windows/msys-20240727/msys2_shell.cmd, opening a msys2 terminal and running ghcup’s stack 3.7.1 to build turtle.

And it built!

Which suggests it’s the MSYS2 difference is the cause., not ghcup’s stack.

Now, when I revert to the independent MSYS2, it returns immediately without error.

Thanks for walking me through the procedure. Otherwise I probably would not have succeeded building turtle.

That was a replication with snapshot: lts-24.37

Replicating the second build against ghc-9.14.1, with ghcup’s stack and MSYS2 at C:\msys64 and $TMP pointing either at C:\msys\tmp or the windows user tmp dir, C:\Users\drbean\AppData\Local\Temp, it fails with

$  TEMP=/c/Users/drbean/AppData/Local/Temp TMP=/c/Users/drbean/AppData/Local/Temp stack build turtle-1.6.2

Warning: Ignoring tagged's bounds on template-haskell (>=2.11 && <2.24) and using template-haskell-2.24.0.0.
         Reason: trusting snapshot over Cabal file dependency information.
StateVar                           > configure
assoc                              > configure
assoc                              > Configuring assoc-1.1.1...
StateVar                           > Configuring StateVar-1.2.2...
assoc                              > C:\WINDOWS\: openBinaryTempFileWithDefaultPermissions: permission denied (Permission denied)
StateVar                           > C:\WINDOWS\: openBinaryTempFileWithDefaultPermissions: permission denied (Permission denied)
Progress 2/51

Error: [S-7282]
       Stack failed to execute the build plan.

       While executing the build plan, Stack encountered the following errors:

       [S-7011]
       While building package StateVar-1.2.2 (scroll up to its section to see the error) using:
       C:\Users\drbean\AppData\Roaming\stack\setup-exe-cache\x86_64-windows\Cabal-simple_O_vy6YIf_3.16.0.0_ghc-9.14.1.exe --verbose=1
--builddir=.stack-work\dist\505eed1c configure --with-ghc=C:\ghcup\bin\ghc-9.14.1.exe --with-ghc-pkg=C:\ghcup\bin\ghc-pkg-9.14.1.exe -
-user --package-db=clear --package-db=global --package-db=C:\Users\drbean\AppData\Roaming\stack\snapshots\9d06473a\pkgdb --libdir=C:\U
sers\drbean\AppData\Roaming\stack\snapshots\9d06473a\lib --bindir=C:\Users\drbean\AppData\Roaming\stack\snapshots\9d06473a\bin --datad
ir=C:\Users\drbean\AppData\Roaming\stack\snapshots\9d06473a\share --libexecdir=C:\Users\drbean\AppData\Roaming\stack\snapshots\9d06473
a\libexec --sysconfdir=C:\Users\drbean\AppData\Roaming\stack\snapshots\9d06473a\etc --docdir=C:\Users\drbean\AppData\Roaming\stack\sna
pshots\9d06473a\doc\StateVar-1.2.2 --htmldir=C:\Users\drbean\AppData\Roaming\stack\snapshots\9d06473a\doc\StateVar-1.2.2 --haddockdir=
C:\Users\drbean\AppData\Roaming\stack\snapshots\9d06473a\doc\StateVar-1.2.2 --dependency=base=base-4.22.0.0-fd17 --dependency=stm=stm-
2.5.3.1-5491 --dependency=transformers=transformers-0.6.1.2-f688 --extra-include-dirs=C:\ghcup\msys64\ucrt64\include --extra-include-d
irs=C:\Users\drbean\AppData\Roaming\stack\programs\x86_64-windows\msys2-20240727\ucrt64\include --extra-lib-dirs=C:\ghcup\msys64\ucrt6
4\lib --extra-lib-dirs=C:\ghcup\msys64\ucrt64\bin --extra-lib-dirs=C:\Users\drbean\AppData\Roaming\stack\programs\x86_64-windows\msys2
-20240727\ucrt64\lib --extra-lib-dirs=C:\Users\drbean\AppData\Roaming\stack\programs\x86_64-windows\msys2-20240727\ucrt64\bin --exact-
configuration --ghc-option=-fhide-source-paths
       Process exited with code: ExitFailure 1


with a smilar error for assoc-1.1.1

But again with stack’s MSYS2 it succeeds in 51 steps, 9 more than the 42(?) with lts-24.27

According to a note at the end of setup - Stack

Aiming to avoid long file paths, Stack does so in a temporary directory (named stack-tmp-<hash>) on the drive of the final destination (either in the system temporary directory, where applicable, or the root of the drive). Consequently, Stack needs permission to create a directory in that location.

A Windows user account will usually have permission to create a directory in the system temporary directory.

Shouldn’t it be trying to create one in the USER temporary directory,

C:\Users\drbean>echo %TMP% or %TEMP%
C:\Users\drbean\AppData\Local\Temp or C:\Users\drbean\AppData\Local\Temp

I cannot access C:\WINDOWS\Temp

C:\Users\drbean>dir C:\WINDOWS
 Volume in drive C has no label.
 Volume Serial Number is 600C-007E

 Directory of C:\WINDOWS

2026/01/25  15:14    <DIR>          .
2026/01/25  15:14    <DIR>          ..
2019/12/08  00:11    <DIR>          addins
2024/10/18  20:01    <DIR>          appcompat
2025/10/15  17:26    <DIR>          apppatch
2026/04/19  16:19    <DIR>          AppReadiness
2016/04/06  19:08           175,956 ARIALN.tt2
...
2022/12/21  11:04    <DIR>          Tasks
2026/04/19  16:33    <DIR>          Temp
2022/12/01  10:12    <DIR>          TextInput
2015/11/20  21:15    <DIR>          ToastData
2019/12/07  18:14    <DIR>          tracing
2023/11/15  23:40    <DIR>          twain_32
2025/05/15  16:54            76,800 twain_32.dll
2022/12/02  14:20    <DIR>          UpdateAssistant
2013/08/23  00:36    <DIR>          vpnplugins
2019/12/07  18:14    <DIR>          Vss
2019/12/07  18:14    <DIR>          WaaS
2019/12/07  18:31    <DIR>          Web
...
C:\Users\drbean>dir C:\WINDOWS\Temp
 Volume in drive C has no label.
 Volume Serial Number is 600C-007E

 Directory of C:\WINDOWS\Temp

File Not Found

C:\Users\drbean>dir C:\WINDOWS\Web
 Volume in drive C has no label.
 Volume Serial Number is 600C-007E

 Directory of C:\WINDOWS\Web

2019/12/07  18:31    <DIR>          .
2019/12/07  18:31    <DIR>          ..
2019/12/07  18:31    <DIR>          4K
2019/12/07  18:15    <DIR>          Screen
2024/03/14  19:32    <DIR>          Wallpaper
               0 File(s)              0 bytes
               5 Dir(s)  282,429,677,568 bytes free

The 2 ghc files in the user tmp directory from today,

C:\Users\drbean>dir C:\Users\drbean\AppData\Local\Temp\ghc*
 Volume in drive C has no label.
 Volume Serial Number is 600C-007E

 Directory of C:\Users\drbean\AppData\Local\Temp

2026/04/19  15:55    <DIR>          ghc11132_tmp_0_0
2026/04/16  16:08            78,336 ghc11D2.exe
2026/04/16  16:08            78,336 ghc3E12.exe
2026/04/19  15:54            81,408 ghcCD21.exe
2026/04/19  15:54            81,408 ghcCD22.exe
2026/04/16  18:23            81,408 ghcD835.exe
               5 File(s)        400,896 bytes
               1 Dir(s)  282,432,884,736 bytes free

Would they be from stack’s MSYS2 builds or the 'C:\msys64 ones?

The ‘temporary’ ghc<hash>.exe files are created by GHC itself. (For some reason, GHC does not clean them up (at least, not on Windows).)

I don’t know why anything would be trying to access C:\WINDOWS\Temp on your machine. On my machine, in PowerShell (TMP is the same):

> dir Env:TEMP

Name                           Value
----                           -----
TEMP                           C:\Users\mike\AppData\Local\Temp

and in the Stack-supplied MSYS2 shell (extracts only):

$ env
...
MSYSTEM=MSYS
...
ORIGINAL_TEMP=/c/Users/mike/AppData/Local/Temp
...
STACK_ROOT=D:\sr
...
TEMP=/tmp
...
ORIGINAL_TMP=/c/Users/mike/AppData/Local/Temp
...
GHCUP_MSYS2_ENV=MINGW64
...
TMP=/tmp
...
GHCUP_MSYS2=D:\sr\programs\x86_64-windows\msys2-20240727
...

where the ‘actual’ path for / is:

$ cygpath -w /
D:\sr\programs\x86_64-windows\msys2-20240727\

Extra verbosity might reveal something. For full-fat verbosity (Stack’s, Cabal’s and GHC’s), command:

stack --verbose build --cabal-verbose --ghc-options=-v turtle

(EDIT: --ghc-options=-v4 is probably too verbose.)

On Sun, 19 Apr 2026, Mike Pilgrem wrote:

and in the Stack-supplied MSYS2 shell (extracts only):

$ env
...
MSYSTEM=MSYS

I was running stack in a UCRT64 environment shell

MSYSTEM=UCRT64
MSYSTEM_PREFIX=/ucrt64

I will try again in a plain MSYS one.

GHCUP_MSYS2_ENV was the same, but I didn’t have
GHCUP_MSYS2 or any STACK ones.

$ cygpath -w /
D:\sr\programs\x86_64-windows\msys2-20240727\

Here,
$ cygpath -w /
C:\msy64\

Extra verbosity might reveal something. For full-fat verbosity (Stack’s, Cabal’s and GHC’s), command:

stack --verbose build --cabal-verbose --ghc-options=-v turtle

This is with snapshot lts-24.37

I tried posting all the output, but failed, exceeding
the 32000 character limit.

Posting just a few lines before the failure,

%< cut >%

2026-04-21 17:22:59.659342: [info] assoc                              > Wanted build ways: [StaticWay]
2026-04-21 17:22:59.659342: [info] assoc                              > Running: "C:\ghcup\bin\ghc-9.10.3.exe" "--make" "-fbuilding-cabal-package" "-O" "-outputdir" ".stack-work\dist\1a191874\build" "-odir" ".stack-work\dist\1a191874\build" "-hidir" ".stack-work\dist\1a191874\build" "-hiedir" ".stack-work\dist\1a191874\build\extra-compilation-artifacts\hie" "-stubdir" ".stack-work\dist\1a191874\build" "-i" "-isrc" "-i.stack-work\dist\1a191874\build" "-i.stack-work\dist\1a191874\build\autogen" "-i.stack-work\dist\1a191874\build\global-autogen" "-I.stack-work\dist\1a191874\build\autogen" "-I.stack-work\dist\1a191874\build\globa
+l-autogen" "-I.stack-work\dist\1a191874\build" "-IC:\ghcup\msys64\ucrt64\include" "-IC:\Users\drbean\AppData\Roaming\stack\programs\x86_64-windows\msys2-20240727\ucrt64\include" "-optP-include" "-optP.stack-work\dist\1a191874\build\autogen\cabal_macros.h" "-this-unit-id" "assoc-1.1.1-F1tRInYZuki6uqqOQoYdnz" "-hide-all-packages" "-Wmissing-home-modules" "-no-user-package-db" "-package-db" "C:\Users\drbean\AppData\Roaming\stack\snapshots\abda8635\pkgdb" "-package-db" ".stack-work\dist\1a191874\package.conf.inplace" "-package-id" "base-4.20.2.0-39f9" "-XHaskell2010" "Data.Bifunctor.Assoc" "Data.Bifunctor.Swap" "-fhide-source-pa
+ths"
2026-04-21 17:22:59.659342: [info] StateVar                           > creating .stack-work\dist\1a191874\build
2026-04-21 17:22:59.659342: [info] StateVar                           > creating .stack-work\dist\1a191874\build\autogen
2026-04-21 17:22:59.674965: [info] StateVar                           > creating .stack-work\dist\1a191874\build\autogen
2026-04-21 17:22:59.674965: [info] StateVar                           > creating .stack-work\dist\1a191874\build\autogen
2026-04-21 17:22:59.674965: [info] StateVar                           > creating .stack-work\dist\1a191874\build\autogen
2026-04-21 17:22:59.674965: [info] StateVar                           > Preprocessing library for StateVar-1.2.2...
2026-04-21 17:22:59.674965: [info] StateVar                           > Building library for StateVar-1.2.2...
2026-04-21 17:22:59.674965: [info] StateVar                           > creating .stack-work\dist\1a191874\build
2026-04-21 17:22:59.674965: [info] StateVar                           > creating .stack-work\dist\1a191874\build
2026-04-21 17:22:59.674965: [info] StateVar                           > Wanted build ways: [StaticWay]
2026-04-21 17:22:59.674965: [info] StateVar                           > Running: "C:\ghcup\bin\ghc-9.10.3.exe" "--make" "-fbuilding-cabal-package" "-O" "-outputdir" ".stack-work\dist\1a191874\build" "-odir" ".stack-work\dist\1a191874\build" "-hidir" ".stack-work\dist\1a191874\build" "-hiedir" ".stack-work\dist\1a191874\build\extra-compilation-artifacts\hie" "-stubdir" ".stack-work\dist\1a191874\build" "-i" "-isrc" "-i.stack-work\dist\1a191874\build" "-i.stack-work\dist\1a191874\build\autogen" "-i.stack-work\dist\1a191874\build\global-autogen" "-I.stack-work\dist\1a191874\build\autogen" "-I.stack-work\dist\1a191874\build\globa
+l-autogen" "-I.stack-work\dist\1a191874\build" "-IC:\ghcup\msys64\ucrt64\include" "-IC:\Users\drbean\AppData\Roaming\stack\programs\x86_64-windows\msys2-20240727\ucrt64\include" "-optP-DUSE_DEFAULT_SIGNATURES=1" "-optP-include" "-optP.stack-work\dist\1a191874\build\autogen\cabal_macros.h" "-this-unit-id" "StateVar-1.2.2-CdQlFIDAcAmBWGT95jJYkz" "-hide-all-packages" "-Wmissing-home-modules" "-no-user-package-db" "-package-db" "C:\Users\drbean\AppData\Roaming\stack\snapshots\abda8635\pkgdb" "-package-db" ".stack-work\dist\1a191874\package.conf.inplace" "-package-id" "base-4.20.2.0-39f9" "-package-id" "stm-2.5.3.1-7044" "-packag
+e-id" "transformers-0.6.1.1-bf2e" "-XHaskell2010" "Data.StateVar" "-Wall" "-Wcompat" "-Winferred-safe-imports" "-Wmissing-safe-haskell-mode" "-fhide-source-paths"
2026-04-21 17:23:04.921584: [warn] StateVar                           > C:\WINDOWS\ghc7744_0: CreateDirectory "\\\\?\\C:\\WINDOWS\\ghc7744_0": permission denied (アクセスが拒否されました。)
2026-04-21 17:23:04.921584: [warn] assoc                              > C:\WINDOWS\ghc6016_0: CreateDirectory "\\\\?\\C:\\WINDOWS\\ghc6016_0": permission denied (アクセスが拒否されました。)
2026-04-21 17:23:05.030953: [debug] Checking for project config at: C:\Users\drbean\turtle-1.6.2\stack.yaml
2026-04-21 17:23:05.030953: [debug] Checking for project config at: C:\Users\drbean\stack.yaml
2026-04-21 17:23:05.030953: [debug] Checking for project config at: C:\Users\stack.yaml
2026-04-21 17:23:05.030953: [debug] Checking for project config at: C:\stack.yaml
2026-04-21 17:23:05.030953: [debug] No project config file found, using defaults.
2026-04-21 17:23:05.046577: [debug] Use of Casa server enabled: (CasaRepoPrefix "https://casa.stackage.org", 1280).
2026-04-21 17:23:05.046577: [debug] (SQL) SELECT COUNT(*) FROM "last_performed" WHERE ("action"=?) AND ("timestamp">=?); [PersistInt64 1,PersistUTCTime 2026-04-20 08:23:05.0465775 UTC]
2026-04-21 17:23:05.046577: [error]
Error: [S-7282]
       Stack failed to execute the build plan.

       While executing the build plan, Stack encountered the following errors:

       [S-7011]
       While building package assoc-1.1.1 (scroll up to its section to see the error) using:
       C:\Users\drbean\AppData\Roaming\stack\setup-exe-cache\x86_64-windows\Cabal-simple_O_vy6YIf_3.12.1.0_ghc-9.10.3.exe --verbose=2 --builddir=.stack-work\dist\1a191874 build --ghc-options ""
       Process exited with code: ExitFailure 1

       [S-7011]
       While building package StateVar-1.2.2 (scroll up to its section to see the error) using:
       C:\Users\drbean\AppData\Roaming\stack\setup-exe-cache\x86_64-windows\Cabal-simple_O_vy6YIf_3.12.1.0_ghc-9.10.3.exe --verbose=2 --builddir=.stack-work\dist\1a191874 build --ghc-options ""
       Process exited with code: ExitFailure 1

Diffing this with the corresponding output when run in
stack’s MSYS2 shell doesn’t reveal any differences
which seem significant (on a quick look).

But at the point where the build fails above, it has:

2026-04-21 17:47:15.379025: [info] StateVar                           > Wanted build ways: [StaticWay]
2026-04-21 17:47:15.379025: [info] assoc                              > Preprocessing library for assoc-1.1.1...
2026-04-21 17:47:15.379025: [info] StateVar                           > Running: "C:\ghcup\bin\ghc-9.10.3.exe" "--make" "-fbuilding-cabal-package" "-O" "-outputdir" ".stack-work\dist\1a191874\build" "-odir" ".stack-work\dist\1a191874\build" "-hidir" ".stack-work\dist\1a1
91874\build" "-hiedir" ".stack-work\dist\1a191874\build\extra-compilation-artifacts\hie" "-stubdir" ".stack-work\dist\1a191874\build" "-i" "-isrc" "-i.stack-work\dist\1a191874\build" "-i.stack-work\dist\1a191874\build\autogen" "-i.stack-work\dist\1a191874\build\global-au
togen" "-I.stack-work\dist\1a191874\build\autogen" "-I.stack-work\dist\1a191874\build\global-autogen" "-I.stack-work\dist\1a191874\build" "-IC:\ghcup\msys64\ucrt64\include" "-IC:\Users\drbean\AppData\Roaming\stack\programs\x86_64-windows\msys2-20240727\ucrt64\include" "-
optP-DUSE_DEFAULT_SIGNATURES=1" "-optP-include" "-optP.stack-work\dist\1a191874\build\autogen\cabal_macros.h" "-this-unit-id" "StateVar-1.2.2-CdQlFIDAcAmBWGT95jJYkz" "-hide-all-packages" "-Wmissing-home-modules" "-no-user-package-db" "-package-db" "C:\Users\drbean\AppDat
a\Roaming\stack\snapshots\abda8635\pkgdb" "-package-db" ".stack-work\dist\1a191874\package.conf.inplace" "-package-id" "base-4.20.2.0-39f9" "-package-id" "stm-2.5.3.1-7044" "-package-id" "transformers-0.6.1.1-bf2e" "-XHaskell2010" "Data.StateVar" "-Wall" "-Wcompat" "-Winferred-safe-imports" "-Wmissing-safe-haskell-mode" "-fhide-source-paths"
2026-04-21 17:47:15.379025: [info] assoc                              > Building library for assoc-1.1.1...
2026-04-21 17:47:15.379025: [info] assoc                              > creating .stack-work\dist\1a191874\build
2026-04-21 17:47:15.379025: [info] assoc                              > creating .stack-work\dist\1a191874\build
2026-04-21 17:47:15.379025: [info] assoc                              > Wanted build ways: [StaticWay]
2026-04-21 17:47:15.379025: [info] assoc                              > Running: "C:\ghcup\bin\ghc-9.10.3.exe" "--make" "-fbuilding-cabal-package" "-O" "-outputdir" ".stack-work\dist\1a191874\build" "-odir" ".stack-work\dist\1a191874\build" "-hidir" ".stack-work\dist\1a191874\build" "-hiedir" ".stack-work\dist\1a191874\build\extra-compilation-artifacts\hie" "-stubdir" ".stack-work\dist\1a191874\build" "-i" "-isrc" "-i.stack-work\dist\1a191874\build" "-i.stack-work\dist\1a191874\build\autogen" "-i.stack-work\dist\1a191874\build\global-autogen" "-I.stack-work\dist\1a191874\build\autogen" "-I.stack-work\dist\1a191874\build\global-autogen" "-I.stack-work\dist\1a191874\build" "-IC:\ghcup\msys64\ucrt64\include" "-IC:\Users\drbean\AppData\Roaming\stack\programs\x86_64-windows\msys2-20240727\ucrt64\include" "-optP-include" "-optP.stack-work\dist\1a191874\build\autogen\cabal_macros.h" "-this-unit-id" "assoc-1.1.1-F1tRInYZuki6uqqOQoYdnz" "-hide-all-packages" "-Wmissing-home-modules" "-no-user-package-db" "-package-db" "C:\Users\drbean\AppData\Roaming\stack\snapshots\abda8635\pkgdb" "-package-db" ".stack-work\dist\1a191874\package.conf.inplace" "-package-id" "base-4.20.2.0-39f9" "-XHaskell2010" "Data.Bifunctor.Assoc" "Data.Bifunctor.Swap" "-fhide-source-paths"
2026-04-21 17:47:17.548427: [info] assoc                              > [1 of 2] Compiling Data.Bifunctor.Assoc
2026-04-21 17:47:17.564054: [info] StateVar                           > [1 of 1] Compiling Data.StateVar
2026-04-21 17:47:21.391836: [warn] StateVar                           > C:\Users\drbean\AppData\Roaming\stack\programs\x86_64-windows\msys2-20240727\tmp\stack-6c0733bca89f22e2\StateVar-1.2.2\src\Data\StateVar.hs:220:33: warning: [GHC-58520] [-Wtype-equality-requires-operators]
2026-04-21 17:47:21.391836: [warn] StateVar                           >     The use of ‘~’ without TypeOperators
2026-04-21 17:47:21.391836: [warn] StateVar                           >     will become an error in a future GHC release.
2026-04-21 17:47:21.407463: [warn] StateVar                           >     Suggested fix: Perhaps you intended to use TypeOperators
2026-04-21 17:47:21.407463: [warn] StateVar                           >     |
2026-04-21 17:47:21.407463: [warn] StateVar                           > 220 |   default ($~) :: (MonadIO m, a ~ b, HasGetter t a) => t -> (a -> b) -> m ()
2026-04-21 17:47:21.407463: [warn] StateVar                           >     |                                 ^
2026-04-21 17:47:21.407463: [warn] StateVar                           >
...
etc
%< cut >%

There doesn’t seem to be any indication of where it’s storing the result of the assoc, StateVar package(?) precompilications.

Taking a hint from 2.2. Installing on Windows

which says it uses Windows GetTempPath, which uses:

  • The path in the environment variable TMP, if TMP is set.
    
    Otherwise, the path in the environment variable TEMP, if TEMP is set.
    
    Otherwise, there is a per-user default which varies between versions of Windows. On NT and XP-ish versions, it might be: c:\Documents and Settings\<username>\Local Settings\Temp
    

(This looks like old documentation.),

I removed TMP and TEMP from the environment, (and ran stack build in the MINGW64 MSYS environment because ghcup appears to want it, with GHCUP_MSYS2_ENV=MINGW64).

It failed after getting I guess dependencies, with

2026-05-07 21:38:16.040999: [debug] Checking if we are going to build multiple executables with the same name
2026-05-07 21:38:16.056613: [debug] Executing the build plan
2026-05-07 21:38:16.119120: [error] C:\Users\drbean\AppData\Roaming\stack\䧩\stack-e3aa6d2b091e2520: CreateDirectory “\\?\C:\Users\drbean\AppData\Roaming\stack\\18921\stack-e3aa6d2b091e2520”: does not exist (指定され
たパスが見つかりません。)

The strange Chinese character appears to be the spurious ‘\18921’ in the other locale. The Japanese says, 'The specified path cannot be found.

If I run ‘stack build’ in c:\Users\drbean\AppData\Local\Temp rather than the stack directory it appears to be looking for a subdir there..

2026-05-07 22:44:35.295976: [debug] Checking if we are going to build multiple executables with the same name
2026-05-07 22:44:35.295976: [debug] Executing the build plan
2026-05-07 22:44:35.311596: [error] C:\Users\drbean\AppData\Local\Temp\濠\stack-d06f3642425d3259: CreateDirectory "\\\\?\\C:\\Users\\drbean\\AppData\\Local\\Temp\\\28640\\stack-d06f3642425d3259": does not exist (指定されたパス
が見つかりません。)

And if I set TMP=C:\Users\drbean\AppData\Local\Temp it goes back to ‘Permission denied’ in C:\Windows