[Git][ghc/ghc][master] hadrian: warn when package index is missing (#16484)
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 8cb99552 by Sylvain Henry at 2026-04-16T19:22:43-04:00 hadrian: warn when package index is missing (#16484) Since cabal-install 3.0 we can query the path of remote-repo-cache and check if hackage package index is present. Fixes #16484 - - - - - 3 changed files: - + changelog.d/hadrian-warn-missing-package-index-16484 - hadrian/build-cabal - hadrian/build-cabal.bat Changes: ===================================== changelog.d/hadrian-warn-missing-package-index-16484 ===================================== @@ -0,0 +1,5 @@ +section: packaging +synopsis: Hadrian now warns when the Hackage package index is missing instead of + failing with an unhelpful error message. +issues: #16484 +mrs: !15878 ===================================== hadrian/build-cabal ===================================== @@ -23,14 +23,19 @@ fi CABVERSTR=$("$CABAL" --numeric-version) CABVER=( ${CABVERSTR//./ } ) -if [ "${CABVER[0]}" -gt 2 -o "${CABVER[0]}" -eq 2 -a "${CABVER[1]}" -ge 2 ]; -then - "$CABAL" --project-file="$PROJ" new-build "${CABFLAGS[@]}" -j exe:hadrian - # use new-exec instead of new-run to make sure that the build-tools (alex & happy) are in PATH - "$CABAL" --project-file="$PROJ" new-exec "${CABFLAGS[@]}" hadrian -- \ - --directory "$PWD" \ - "$@" -else +if [ "${CABVER[0]}" -lt 3 ]; then echo "Cabal version is too old; you need at least cabal-install 3.0" exit 2 fi + +REMOTE_REPO_CACHE=$("$CABAL" --with-compiler="$GHC" path --output-format=key-value 2>/dev/null | awk '/^remote-repo-cache:/ { print $2 }') +if ! [ -d "$REMOTE_REPO_CACHE/hackage.haskell.org" ]; then + echo "Please run 'cabal update' first" + exit 2 +fi + +"$CABAL" --project-file="$PROJ" new-build "${CABFLAGS[@]}" -j exe:hadrian +# use new-exec instead of new-run to make sure that the build-tools (alex & happy) are in PATH +"$CABAL" --project-file="$PROJ" new-exec "${CABFLAGS[@]}" hadrian -- \ + --directory "$PWD" \ + "$@" ===================================== hadrian/build-cabal.bat ===================================== @@ -34,18 +34,20 @@ for /F "delims=. tokens=1,2,3,4" %%a in ("%CABVERSTR%") do ( set CABPATCH=%%d ) -set "_cabal_ok=0" -if %CABMAJOR% gtr 2 set _cabal_ok=1 -if %CABMAJOR% equ 2 ( - if %CABMINOR% geq 2 set _cabal_ok=1 -) -if %_cabal_ok% equ 1 ( - "%CABAL%" --project-file=%PROJ% new-build %CABFLAGS% -j exe:hadrian - rem use new-exec instead of new-run to make sure that the build-tools (alex & happy) are in PATH - "%CABAL%" --project-file=%PROJ% new-exec %CABFLAGS% hadrian -- ^ - --directory "%CD%" ^ - %* -) else ( - echo Cabal version is too old; you need at least cabal-install 2.2 +if %CABMAJOR% lss 3 ( + echo Cabal version is too old; you need at least cabal-install 3.0 exit /B 2 ) + +for /F "tokens=*" %%a in ('"%CABAL%" --with-compiler=%GHC% path --output-format=key-value 2^>NUL ^| findstr /B "remote-repo-cache:"') do set REMOTE_REPO_CACHE=%%a +set REMOTE_REPO_CACHE=%REMOTE_REPO_CACHE:remote-repo-cache: =% +if not exist "%REMOTE_REPO_CACHE%\hackage.haskell.org" ( + echo Please run 'cabal update' first + exit /B 2 +) + +"%CABAL%" --project-file=%PROJ% new-build %CABFLAGS% -j exe:hadrian +rem use new-exec instead of new-run to make sure that the build-tools (alex & happy) are in PATH +"%CABAL%" --project-file=%PROJ% new-exec %CABFLAGS% hadrian -- ^ + --directory "%CD%" ^ + %* View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8cb99552f607f6bc4000e45ab32532d5... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/8cb99552f607f6bc4000e45ab32532d5... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Marge Bot (@marge-bot)