Stack tries to create temporary folder in drive root?

This appears to have interoperatability problems running stack install turtle in a MSYS2 shell. Perhaps because MSYS2 is setting TMP envar to /tmp.

drbean@ESPRIMO MSYS ~/turtle
$ stack install turtle

Warning: Trouble loading CompilerPaths cache:

         Error: [S-8196]
         Compiler file metadata mismatch, ignoring cache.
         HasCallStack backtrace:
           collectBacktraces, called at libraries\ghc-internal\src\GHC\Internal\Exception.hs:169:13 in ghc-internal:GHC.Internal.Excep
tion
           toExceptionWithBacktrace, called at libraries\ghc-internal\src\GHC\Internal\IO.hs:260:11 in ghc-internal:GHC.Internal.IO
           throwIO, called at src\UnliftIO\Exception.hs:441:20 in unliftio-0.2.25.1-JcxvxdKc0Ho9WcM1iVvrDp:UnliftIO.Exception


C:\WINDOWS\ghc7176_tmp_0_0: CreateDirectory "\\\\?\\C:\\WINDOWS\\ghc7176_tmp_0_0": permission denied (アクセスが拒否されました。)

Error: [S-6374]
       While building simple Setup.hs (scroll up to its section to see the error) using:
       C:\ghcup\bin\ghc-9.14.1.exe -rtsopts -threaded -clear-package-db -global-package-db -hide-all-packages -package base -main-is S
tackSetupShim.mainOverride -package Cabal-3.16.0.0 C:\Users\drbean\AppData\Roaming\stack\setup-exe-src\setup-O_vy6YIf.hs C:\Users\drbe
an\AppData\Roaming\stack\setup-exe-src\setup-shim-O_vy6YIf.hs -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
       Process exited with code: ExitFailure 1

But run in a Windows cmd shell:

    C:\Users\drbean\turtle>\ghcup\bin\stack.exe install turtle

Warning: Stack is not using a Stack-supplied MSYS2.
[1 of 3] Compiling Main             ( C:\Users\drbean\AppData\Roaming\stack\setup-exe-src\setup-O_vy6YIf.hs, C:\Users\drbean\AppData\Roaming\stack\setup-exe-src\setup-O_vy6YIf.o )
[2 of 3] Compiling StackSetupShim   ( C:\Users\drbean\AppData\Roaming\stack\setup-exe-src\setup-shim-O_vy6YIf.hs, C:\Users\drbean\AppData\Roaming\stack\setup-exe-src\setup-shim-O_vy6YIf.o )
[3 of 3] Linking 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
turtle> configure (lib + exe)
Configuring turtle-0.1.0.0...
turtle> build (lib + exe) with ghc-9.14.1
Preprocessing library for turtle-0.1.0.0...
Building library for turtle-0.1.0.0...
[1 of 2] Compiling Lib
[2 of 2] Compiling Paths_turtle
Preprocessing executable 'turtle-exe' for turtle-0.1.0.0...
Building executable 'turtle-exe' for turtle-0.1.0.0...
[1 of 2] Compiling Main
[2 of 2] Compiling Paths_turtle
[3 of 3] Linking .stack-work\dist\505eed1c\build\turtle-exe\turtle-exe.exe
turtle> copy/register
Installing library in C:\Users\drbean\turtle\.stack-work\install\111e7964\lib\x86_64-windows-ghc-9.14.1-bd8b\turtle-0.1.0.0-LODE549nfonHFTMblztAkN
Installing executable turtle-exe in C:\Users\drbean\turtle\.stack-work\install\111e7964\bin
Registering library for turtle-0.1.0.0...
Copying from C:\Users\drbean\turtle\.stack-work\install\111e7964\bin\turtle-exe.exe to
C:\Users\drbean\AppData\Roaming\local\bin\turtle-exe.exe.
Copied executables to C:\Users\drbean\AppData\Roaming\local\bin\:
* turtle-exe.exe

Warning: Installation path C:\Users\drbean\AppData\Roaming\local\bin not found on the PATH environment variable.

C:\Users\drbean\turtle>

MSYS2 somewhere is setting TMP envar to /tmp for its own tmp files. The Windows envars:

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

A lot of windows tmp files are there.

I have a C:\tmp directory with my permissions of user. One cygwin(?) app is using it.

Running stack install turtle again in the MSYS2 shell, I get,

C:\WINDOWS\: openBinaryTempFileWithDefaultPermissions: permission denied (Permission denied)