Skip to content

Breaking change in importing packages? #8795

Open
@philderbeast

Description

@philderbeast

Describe the bug
I installed cabal-install from source and noticed a breaking change. I took the test from #8686 and created a similar test that shows the problem.

$ pwd
/.../cabal/cabal-testsuite/ProjectTests/Import/PackageGroups
$ tree
.
├── cabal-configs
│   ├── pkg-groups
│   │   └── dep1-dep2.config
│   └── pkgs.config
├── cabal.out
├── cabal.project
├── cabal.test.hs
├── dep1
│   ├── dep1.cabal
│   └── Dep1.hs
├── dep2
│   ├── dep2.cabal
│   └── Dep2.hs
├── Lib.hs
└── main.cabal

Stepping through the indirection of imports:

$ cat cabal.project
import: cabal-configs/pkgs.config

packages:
    ./
$ cat cabal-configs/pkgs.config 
import: cabal-configs/pkg-groups/dep1-dep2.config
$ cat cabal-configs/pkg-groups/dep1-dep2.config 
packages:
    ./dep1/
  , ./dep2/
$ 

In the reproduction, if I import the packages in 1-hop then we're good but in 2-hops we break (when we didn't before).

-- Importing packages in one hop works. Uncomment the line below to see that.
-- import: cabal-configs/pkg-groups/dep1-dep2.config

-- Importing the same packages in two hops works with cabal-install-3.8.1.0 but fails now.
import: cabal-configs/pkgs.config

packages:
    ./

To Reproduce
First off with v3.8.1.0 (this works):

$ ~/.ghcup/bin/cabal clean --project-file=./cabal.project
$ ~/.ghcup/bin/cabal build all --dry-run --project-file=./cabal.project
Resolving dependencies...
Build profile: -w ghc-9.2.5 -O1
In order, the following would be built (use -v for more details):
 - dep1-0.1 (lib) (first run)
 - dep2-0.1 (lib) (first run)
 - main-0.1 (lib) (first run)
$ ~/.ghcup/bin/cabal --version
cabal-install version 3.8.1.0
compiled using version 3.8.1.0 of the Cabal library

Then with v3.9.0.0 (this fails):

$ ~/.cabal/bin/cabal clean
$ ~/.cabal/bin/cabal build all --dry-run --project-file=./cabal.project
cabal-configs/cabal-configs/pkg-groups/dep1-dep2.config:
  withBinaryFile: does not exist (No such file or directory)
$ ~/.cabal/bin/cabal --version
cabal-install version 3.9
compiled using version 3.9.0.0 of the Cabal library 

From the error report, cabal has repeated the first part of the path.

- cabal-configs/pkg-groups/dep1-dep2.config
+ cabal-configs/cabal-configs/pkg-groups/dep1-dep2.config

Expected behavior
I like Dhall's stance on imports. Can we do something like that?

"The import resolution phase replaces all imports with the expression located at that import, transitively resolving imports within the imported expression if necessary.
"SOURCE: Import Resolution Judgment

System information

  • Ubuntu 22.04.1 LTS
$ cabal --version
cabal-install version 3.8.1.0
compiled using version 3.8.1.0 of the Cabal library 
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 9.2.5

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions