From f2ad9b37d52da03de16e7b9548bf819d2dde49ae Mon Sep 17 00:00:00 2001 From: Harendra Kumar Date: Thu, 22 Oct 2026 06:25:47 +0530 Subject: [PATCH 1/2] Do not use TEMP as a shell variable name install_hlint and install_docspec set TEMP to a relative download directory and leave it set after they return. TEMP is the Windows temporary directory variable, so programs run later in the same shell would use that directory, which the EXIT trap removes. Use HLINT_TMP_DIR and DOCSPEC_TMP_DIR instead. --- packcheck.sh | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/packcheck.sh b/packcheck.sh index b0ef9a10..f58191c3 100755 --- a/packcheck.sh +++ b/packcheck.sh @@ -2152,15 +2152,15 @@ install_hlint() { VERSION=$HLINT_VERSION URL="$HLINT_URL_PREFIX/download/v$VERSION/hlint-$VERSION-x86_64-$OS$EXT" - TEMP=$(mktemp -d .$PACKAGE-XXXXXX) + HLINT_TMP_DIR=$(mktemp -d .$PACKAGE-XXXXXX) cleanup(){ - rm -r $TEMP + rm -r $HLINT_TMP_DIR } trap cleanup EXIT echo $URL - retry_cmd curl --fail --progress-bar --location -o$TEMP/$PACKAGE$EXT $URL + retry_cmd curl --fail --progress-bar --location -o$HLINT_TMP_DIR/$PACKAGE$EXT $URL if test "$?" -ne 0 then die "Failed to download $URL" @@ -2173,14 +2173,14 @@ install_hlint() { mkdir -p ${LOCAL_BIN} if [ "$OS" = "windows" ]; then - 7z x -y $TEMP/$PACKAGE$EXT -o${TEMP} hlint-$VERSION/hlint.exe > /dev/null - mv ${TEMP}/hlint-${VERSION}/hlint.exe ${LOCAL_BIN} + 7z x -y $HLINT_TMP_DIR/$PACKAGE$EXT -o${HLINT_TMP_DIR} hlint-$VERSION/hlint.exe > /dev/null + mv ${HLINT_TMP_DIR}/hlint-${VERSION}/hlint.exe ${LOCAL_BIN} elif [ "$OS" = "osx" ]; then - tar -xzvf $TEMP/$PACKAGE$EXT -C${TEMP} --include '*/hlint' - mv ${TEMP}/hlint-${VERSION}/hlint ${LOCAL_BIN} + tar -xzvf $HLINT_TMP_DIR/$PACKAGE$EXT -C${HLINT_TMP_DIR} --include '*/hlint' + mv ${HLINT_TMP_DIR}/hlint-${VERSION}/hlint ${LOCAL_BIN} else - tar -xzvf $TEMP/$PACKAGE$EXT -C${TEMP} --wildcards '*/hlint' - mv ${TEMP}/hlint-${VERSION}/hlint ${LOCAL_BIN} + tar -xzvf $HLINT_TMP_DIR/$PACKAGE$EXT -C${HLINT_TMP_DIR} --wildcards '*/hlint' + mv ${HLINT_TMP_DIR}/hlint-${VERSION}/hlint ${LOCAL_BIN} fi chmod +x $HLINT_PATH } @@ -2307,9 +2307,9 @@ install_docspec() { *) die "install_docspec: unknown or unsupported os";; esac - TEMP=$(mktemp -d docspec-XXXXXX) + DOCSPEC_TMP_DIR=$(mktemp -d docspec-XXXXXX) cleanup(){ - rm -r $TEMP + rm -r $DOCSPEC_TMP_DIR } trap cleanup EXIT @@ -2318,10 +2318,10 @@ install_docspec() { # directly instead of version. #URL="$DOCSPEC_URL_PREFIX/download/cabal-docspec-$DOCSPEC_VERSION/cabal-docspec-$DOCSPEC_VERSION-x86_64-$OS.xz" #echo "Downloading $URL ..." - retry_cmd curl --fail --progress-bar --location -o$TEMP/cabal-docspec.xz $DOCSPEC_URL + retry_cmd curl --fail --progress-bar --location -o$DOCSPEC_TMP_DIR/cabal-docspec.xz $DOCSPEC_URL if test "$?" -ne 0 then - rm -f $TEMP/cabal-docspec.xz + rm -f $DOCSPEC_TMP_DIR/cabal-docspec.xz die "Failed to download $DOCSPEC_URL" fi @@ -2330,8 +2330,8 @@ install_docspec() { die "$DOCSPEC_PATH already exists, not overwriting." else mkdir -p $(dirname ${DOCSPEC_PATH}) - xz -d < $TEMP/cabal-docspec.xz > $DOCSPEC_PATH - rm -f $TEMP/cabal-docspec.xz + xz -d < $DOCSPEC_TMP_DIR/cabal-docspec.xz > $DOCSPEC_PATH + rm -f $DOCSPEC_TMP_DIR/cabal-docspec.xz chmod +x $DOCSPEC_PATH fi } From d91731cf46c91b32fd64b307a5fce99ef99b6934 Mon Sep 17 00:00:00 2001 From: Harendra Kumar Date: Thu, 22 Oct 2026 06:25:47 +0530 Subject: [PATCH 2/2] Allow TEMP and TMP on Windows Without them GetTempPath falls back to the Windows directory, so programs create temporary files in C:\Windows. Pass them through in the GitHub workflow template. --- .github/workflows/packcheck.yml | 2 +- Changelog.md | 2 ++ packcheck.sh | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/packcheck.yml b/.github/workflows/packcheck.yml index cb1acc56..e074ee2d 100644 --- a/.github/workflows/packcheck.yml +++ b/.github/workflows/packcheck.yml @@ -427,7 +427,7 @@ jobs: #PATH_VAR="$PATH_VAR:/usr/local/.ghcup/bin" ;; CYGWIN*|MINGW*|MSYS*) - for var in APPDATA CABAL_DIR; do + for var in APPDATA CABAL_DIR TEMP TMP; do val="${!var}" [ -n "$val" ] && ARGS="$ARGS $var=\"$(cygpath -u "$val")\"" done diff --git a/Changelog.md b/Changelog.md index 4b6dbd95..221953d9 100644 --- a/Changelog.md +++ b/Changelog.md @@ -6,6 +6,8 @@ * Add `CABAL_INDEX_TTL` option - do not attempt cabal update until it is stale by this many hours, saves some build time. * Windows: Support installing ghc using ghcup. +* Windows: Allow `TEMP` and `TMP` on the command line, so that programs + use the system temporary directory instead of the Windows directory. * Caching: New `BUILD_ONLY_DEPS` and `BUILD_POST_DEPS` flags to allow pausing/resuming builds for CI cache optimization. * Diagnostics: Enhanced machine info captures `df`, `mount`, and diff --git a/packcheck.sh b/packcheck.sh index f58191c3..144900f9 100755 --- a/packcheck.sh +++ b/packcheck.sh @@ -365,6 +365,8 @@ GHCRTS \ ALLOW_WIN_ENVVARS="\ WINVER \ APPDATA \ +TEMP \ +TMP \ NUMBER_OF_PROCESSORS \ PROCESSOR_IDENTIFIER \ "