Skip to content

Cabal 3.14.1.0 invokes test binaries with a corrupt (duplicated) environment variable list #10718

Closed
@Rufflewind

Description

@Rufflewind

Describe the bug

cabal 3.14.1.0 invokes test binaries with with an invalid environment variable list that contains duplicate entries.

As documented by POSIX: https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/V1_chap08.html

If more than one string in an environment of a process has the same name, the consequences are undefined.

This is causing the directory CI tests to fail: https://github.com/haskell/directory/actions/runs/12595046406

The bug is not found in cabal 3.12.1.0.

To Reproduce

-- Main.hs
module Main where
import Data.List (sort)
import System.Environment (getEnvironment)
main = print =<< fmap sort getEnvironment
-- foo.cabal
cabal-version:      3.0
name:               foo
version:            0.1.0.0
build-type:         Simple

test-suite test
    build-depends:    base
    default-language: Haskell2010
    main-is:          Main.hs
    type:             exitcode-stdio-1.0
$ cabal test

Actual output

[("COLORTERM","truecolor"),("COLORTERM","truecolor"),("DBUS_SESSION_BUS_ADDRESS",...),("DBUS_SESSION_BUS_ADDRESS",...),...

Expected behavior

There should not be any duplicates, i.e.

[("COLORTERM","truecolor"),("DBUS_SESSION_BUS_ADDRESS",...),...

System information

  • Operating system: Tested on Ubuntu (Github Actions) + WSL Debian
  • Reproducible on cabal 3.14.1.0. Not reproducible on cabal 3.12.1.0.
  • Reproducible on several GHC versions.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions