haskell / haskell/cabal

Missing package database if only installing boot packages

Open
#9,310 15 comments 0 reactions 0 assignees View on GitHub
cabal-install: environment-files type: bug
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

**Describe the bug**

I recently installed GHC 9.6.3 and now I ran the command `cabal install --lib --package-env . base ghc`. This creates a environment file like this:

```
clear-package-db
global-package-db
package-db /Users/jaro/.cabal/store/ghc-9.6.3/package.db
package-id base-4.18.1.0
package-id ghc-9.6.3
```

However, I did not actually have a package.db for ghc-9.6.3 yet and this command does not create it. So, now when I try to run GHC using this environment file I get the error:

```
ghc-9.6.3: can't find a package database at /Users/jaro/.cabal/store/ghc-9.6.3/package.db
```

I would expect that this command either would actually ensure that the package db is created (or alternatively leave out that package-db line from the environment file).

To work around this issue I can just run a command that does actually build a package, e.g.: `cabal repl -b tasty`.

**System information**
- Operating system: MacOS
- `cabal` 3.10.1.0, `ghc` 9.6.3

Contributor guide

Open the contributing guide

Research direction

Reproduce `cabal install --lib --package-env . base ghc` with GHC 9.6.3 and inspect the generated environment file and package database handling. Compare this with `cabal repl -b tasty`; the fix should ensure the referenced package database exists or omit the invalid `package-db` entry, with the failing scenario covered by a test.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
build-system, cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.