From b141e7f03fd89223cd031a74d97f44ffe9475862 Mon Sep 17 00:00:00 2001 From: Harendra Kumar Date: Fri, 17 Apr 2026 02:02:28 +0530 Subject: [PATCH 1/3] Issue a warning before unsetting GHC_PACKAGE_PATH --- packcheck.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packcheck.sh b/packcheck.sh index 439c7cd..e230daa 100755 --- a/packcheck.sh +++ b/packcheck.sh @@ -2560,10 +2560,6 @@ setup_environment() { # TOOLS_DIR="$GHCUP_PATH" #fi - # if we are running from a stack environment remove GHC_PACKAGE_PATH so that - # cabal does not complain - # XXX this should be done from outside via env - unset GHC_PACKAGE_PATH # stack does not work well with empty STACK_YAML env var test -n "$STACK_YAML" || unset STACK_YAML @@ -2612,6 +2608,14 @@ case $BUILD in *) ;; esac +# if we are running from a stack environment remove GHC_PACKAGE_PATH so that +# cabal does not complain. +# XXX this should be done from outside via env +# NOTE: do this before eval_env, so that it can later be set by eval_env if +# passed on command line. +echo "WARNING! unsetting GHC_PACKAGE_PATH if you really want to use it pass it on the command line" +unset GHC_PACKAGE_PATH + # This allows only SYSTEM_ENVVARS to be set on the command line eval_env "$@" # After eval_env the PATH changes From 4e27c500a3a324342a9fa9468657d7d1b0e1c584 Mon Sep 17 00:00:00 2001 From: Harendra Kumar Date: Fri, 17 Apr 2026 02:19:45 +0530 Subject: [PATCH 2/3] Do not add a prefix to the PATH --- packcheck.sh | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/packcheck.sh b/packcheck.sh index e230daa..17ec3b8 100755 --- a/packcheck.sh +++ b/packcheck.sh @@ -2540,15 +2540,21 @@ setup_environment() { # XXX add paths only if not already on PATH, but sometimes we have to add path # at head for precedence even if it is already on PATH. #echo "Original PATH is [$PATH]..." - PATH_PREFIX=$LOCAL_BIN:$GHCUP_BIN - if test "$BUILD" = "cabal-v2" - then - PATH_PREFIX=$PATH_PREFIX:$OS_APP_HOME/$OS_CABAL_DIR/bin - fi - echo "Prefixing [$PATH_PREFIX] to PATH" - export PATH=$PATH_PREFIX:$PATH - echo + # We should not add anything to PATH, respect the user's PATH. For example, + # we may be running in a nix shell which has overridden ghc, and adding + # ghcup/bin to the front of PATH will change the ghc and all the packages + # that were available. + # + #PATH_PREFIX=$LOCAL_BIN:$GHCUP_BIN + #if test "$BUILD" = "cabal-v2" + #then + # PATH_PREFIX=$PATH_PREFIX:$OS_APP_HOME/$OS_CABAL_DIR/bin + #fi + + #echo "Prefixing [$PATH_PREFIX] to PATH" + #export PATH=$PATH_PREFIX:$PATH + #echo # XXX we should be able to set multiple paths in it # One advantage of using GHCUP_PATH as TOOLS_DIR is that we can pick ghc right From 7a63cf8e3741009c94a1b02dfca6ed2fedc099e6 Mon Sep 17 00:00:00 2001 From: Harendra Kumar Date: Fri, 17 Apr 2026 03:12:22 +0530 Subject: [PATCH 3/3] Use PATH suffix instead --- packcheck.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/packcheck.sh b/packcheck.sh index 17ec3b8..9fb527b 100755 --- a/packcheck.sh +++ b/packcheck.sh @@ -2541,20 +2541,20 @@ setup_environment() { # at head for precedence even if it is already on PATH. #echo "Original PATH is [$PATH]..." - # We should not add anything to PATH, respect the user's PATH. For example, + # XXX We should not add anything to PATH, respect the user's PATH. For example, # we may be running in a nix shell which has overridden ghc, and adding # ghcup/bin to the front of PATH will change the ghc and all the packages # that were available. # - #PATH_PREFIX=$LOCAL_BIN:$GHCUP_BIN - #if test "$BUILD" = "cabal-v2" - #then - # PATH_PREFIX=$PATH_PREFIX:$OS_APP_HOME/$OS_CABAL_DIR/bin - #fi + PATH_SUFFIX=$LOCAL_BIN:$GHCUP_BIN + if test "$BUILD" = "cabal-v2" + then + PATH_SUFFIX=$PATH_PREFIX:$OS_APP_HOME/$OS_CABAL_DIR/bin + fi - #echo "Prefixing [$PATH_PREFIX] to PATH" - #export PATH=$PATH_PREFIX:$PATH - #echo + echo "Suffixing [$PATH_SUFFIX] to PATH" + export PATH=$PATH:$PATH_SUFFIX + echo # XXX we should be able to set multiple paths in it # One advantage of using GHCUP_PATH as TOOLS_DIR is that we can pick ghc right