diff --git a/changelog.d/pr-10684.md b/changelog.d/pr-10684.md new file mode 100644 index 00000000000..34a72e40718 --- /dev/null +++ b/changelog.d/pr-10684.md @@ -0,0 +1,74 @@ +--- +synopsis: "A project target is required for the REPL command" +packages: [cabal-install] +prs: 10684 +issues: 10527 +--- + +With a project, the REPL command requires a target. If one is not given then a +message is shown explaining this and naming the project if the `--project-file` +option was given (but not when the default 'cabal.project' project name is used +implicitly). We're not yet able to list project targets so in the meantime, the +messages lists the packages of the project. + +* When the implicit default `cabal.project` is used: + +``` +$ cat cabal.project +packages: pkg-one pkg-two + +$ cabal repl +Error: [Cabal-7076] +With a project, the REPL command requires a single target. The packages in this project are: + - pkg-one + - pkg-two +``` + +* When the `--project-file` option is used, the file name is included: + +``` +$ cat some.project +packages: pkg-one pkg-two + +$ cabal repl --project-file=some.project +... +Error: [Cabal-7076] +With a project, the REPL command requires a single target. The packages in this project, 'some.project', are: + - pkg-one + - pkg-two +``` + +* When the project has no packages, this is mentioned in the message: + +``` +$ cat empty.project + +$ cabal repl --project-file=empty.project +... +Error: [Cabal-7076] +With a project, the REPL command requires a single target but there are no +packages in this project, 'empty.project', to choose a package (library) or +other component from as the target for this command. +``` + +* Before the fix the message mentioned a `fake-package-0`. This was confusing: + +``` +$ ~/.ghcup/bin/cabal-3.12.1.0 repl --project-file=some.project +... +Error: [Cabal-7076] +Internal error when trying to open a repl for the package fake-package-0. The +package is not in the set of available targets for the project plan, which would +suggest an inconsistency between readTargetSelectors and resolveTargets. +``` + +* Earlier `cabal-install:exe:cabal` versions mentioned using `all` as the target + but this won't work for the REPL command: + +``` +$ ~/.ghcup/bin/cabal-3.10.3.0 repl --project-file=some.project +Error: cabal-3.10.3.0: No targets given and there is no package in the current +directory. Use the target 'all' for all packages in the project or specify +packages or components by name or location. See 'cabal build --help' for more +details on target options. +```