Deduplicate `LD_LIBRARY_PATH` when running tests (#8728)
commita191f0a2bf72894b3d830ca3ee4ea111d96b6f65
authorRebecca Turner <rbt@sent.as>
Sun, 4 Jun 2023 22:59:40 +0000 (4 18:59 -0400)
committerGitHub <noreply@github.com>
Sun, 4 Jun 2023 22:59:40 +0000 (4 22:59 +0000)
treea672aa5f60824b7acfaf97a65e6db98df0186248
parentc3f92c4c39ad1ed643cf7837182d057f59f3396e
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>
Cabal/src/Distribution/Simple/LocalBuildInfo.hs
changelog.d/pr-8728 [new file with mode: 0644]