Skip to content

Commit de9f58c

Browse files
committed
fix(haskell-language-server): set CABAL_DIR and capture build errors
Without CABAL_DIR, cabal has no writable home for its config, package index, and build store in the sandboxed build environment — the most likely root cause of the 17-minute build failures. Every other Haskell package in the repo (tamarin-prover, stack) sets this; HLS was the only one that didn't. Also add --with-compiler for explicitness, -v1 for verbose output, and an error-capture block (matching tamarin-prover's pattern) that extracts the real compile/link error on failure instead of a bare "build failed" exit.
1 parent bf268a4 commit de9f58c

1 file changed

Lines changed: 22 additions & 3 deletions

File tree

  • packages/haskell-language-server

packages/haskell-language-server/build.sh

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,38 @@ set -euo pipefail
33

44
# The source tarball is already extracted with strip_prefix, so we're in the source root
55

6+
# cabal needs a writable HOME for its config, package index, and build store.
7+
export CABAL_DIR="$PWD/.cabal-home"
8+
mkdir -p "$CABAL_DIR"
9+
610
# Build HLS for the GHC version available in the sandbox
711
export GHC="$(command -v ghc)"
812
export CABAL="$(command -v cabal)"
913

1014
# Update cabal package index
1115
cabal update
1216

13-
# Build HLS with the available GHC version
17+
# Build HLS with the available GHC version. The cabal.project ships with
18+
# tests:True and benchmarks:True, which makes the solver consider test/benchmark
19+
# deps for every transitive dependency — pass --disable-tests/--disable-benchmarks
20+
# to build only the executable.
21+
set +e
1422
cabal build \
1523
--disable-tests \
1624
--disable-benchmarks \
25+
--with-compiler="$(command -v ghc)" \
1726
--ghc-options="-j$(nproc)" \
18-
exe:haskell-language-server
27+
-v1 \
28+
exe:haskell-language-server 2>&1 | tee /tmp/hls-build.log
29+
rc=${PIPESTATUS[0]}
30+
set -e
31+
if [ "$rc" -ne 0 ]; then
32+
echo "===== cabal build failed (rc=$rc) — real error: ====="
33+
grep -iE "\.hs:[0-9]+:[0-9]+: error|error:\s*\[GHC|undefined reference|cannot find -l|panic|internal error|cannot satisfy|conflict" /tmp/hls-build.log | tail -25 \
34+
|| echo "(no error text captured)"
35+
tail -25 /tmp/hls-build.log
36+
exit 1
37+
fi
1938

2039
# Install to OUTPUT_DIR
2140
mkdir -p "$OUTPUT_DIR"/usr/bin
@@ -34,4 +53,4 @@ for lib in $(ldd "$HLS_BIN" | grep '\.so' | awk '{print $3}'); do
3453
cp "$lib" "$OUTPUT_DIR"/usr/lib/
3554
fi
3655
fi
37-
done
56+
done

0 commit comments

Comments
 (0)