Skip to content

Commit a191f0a

Browse files
Deduplicate LD_LIBRARY_PATH when running tests (#8728)
* Deduplicate `LD_LIBRARY_PATH` when running tests When Cabal runs a test suite, it adds all the dependent libraries to `LD_LIBRARY_PATH`. In some cases, this can exceed the operating system's `ARG_MAX` limit: dist/build/test/test: createProcess: posix_spawnp: resource exhausted (Argument list too long) However, many of the entries (observed as high as 75%!) in `LD_LIBRARY_PATH` are duplicates. Deduplicating the list with `Data.List.nub` fixes this error. This error was originally observed when testing a large commercial Haskell project (the mercury.com backend). Ideally, `depLibraryPaths` would be fixed to not return duplicate entries, but this fixup is low-cost and effective. * Add changelog entries --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent c3f92c4 commit a191f0a

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Cabal/src/Distribution/Simple/LocalBuildInfo.hs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,10 @@ depLibraryPaths inplace relative lbi clbi = do
295295
allDepLibDirsC
296296
| otherwise = allDepLibDirsC
297297

298-
return libPaths
298+
-- For some reason, this function returns lots of duplicates. Avoid
299+
-- exceeding `ARG_MAX` (the result of this function is used to populate
300+
-- `LD_LIBRARY_PATH`) by deduplicating the list.
301+
return $ ordNub libPaths
299302
where
300303
-- 'canonicalizePath' fails on UNIX when the directory does not exists.
301304
-- So just don't canonicalize when it doesn't exist.

changelog.d/pr-8728

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
synopsis: Deduplicate LD_LIBRARY_PATH when running tests
2+
packages: Cabal
3+
prs: #8728

0 commit comments

Comments
 (0)