haskell / haskell/cabal

"Use of GHC's environment variable GHC_PACKAGE_PATH is incompatible with Cabal" when running `Setup.hs test` should be a warning, not an error

Open
#10,090 4 comments 0 reactions 0 assignees View on GitHub
needs triage type: bug
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

**Describe the bug**

Cabal throws an error and refuses to proceed when `GHC_PACKAGE_PATH` is set when running the test suite, with this error:

```
Error: [Cabal-8123]
Use of GHC's environment variable GHC_PACKAGE_PATH is incompatible with Cabal. Use the flag --package-db to specify a package database (it can be used multiple times).
```
Previously, it would ignore this environment variable and the test suite would run normally.

**To Reproduce**

Steps to reproduce the behavior:

1. Use [this gist](https://gist.github.com/vaibhavsagar/a1b02e45f5164a1d9597f87f25331d6b).
2. Run the following commands:
```
$ nix-shell
[nix-shell] $ runghc Setup.hs configure --enable-tests
<...>
[nix-shell] $ runghc Setup.hs build
<...>
[nix-shell] $ GHC_PACKAGE_PATH="./dist/package.conf.inplace:$GHC_PACKAGE_PATH" runghc Setup.hs test

Error: [Cabal-8123]
Use of GHC's environment variable GHC_PACKAGE_PATH is incompatible with Cabal. Use the flag --package-db to specify a package database (it can be used multiple times).

```

**Expected behavior**

A warning is displayed but the test suite runs.

**System information**
- NixOS 24.05
- GHC 9.10.1, Cabal-3.12.0.0

**Additional context**

I was using a similar workflow in https://github.com/IHaskell/IHaskell and https://github.com/NixOS/nixpkgs/pull/312859 was introduced into Nixpkgs to work around this issue.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.