Skip to content

confusing error when missing packages: #8679

Open
@dmwit

Description

@dmwit

Describe the bug
If you forget to include a list of packages in your cabal.project, the error looks like this:

Warning: There are no packages or optional-packages in the project
Error: cabal: There is no <pkgname>.cabal package file or cabal.project file.
To build packages locally you need at minimum a <pkgname>.cabal file. You can
use 'cabal init' to create one.

For non-trivial projects you will also want a cabal.project file in the root
directory of your project. This file lists the packages in your project and
all other build configuration. See the Cabal user guide for full details.

The warning is spot-on, but the error is confusing, because it can be printed in exactly that way when there is both a <pkgname>.cabal file and a cabal.project file available. For people (like me) that tend to gloss over warnings if there's an error available, that's bad news.

To Reproduce

$ mkdir t
$ cd t
$ touch cabal.project
$ cabal v2-run t

Expected behavior
I'm not sure, but probably just rewriting the error is sufficient. Let it reflect more accurately what actual check is being done in the code.

System information

  • cabal-install 3.8.1.0, Cabal 3.8.1.0
  • ghc and OS versions are irrelevant I'm pretty sure, but just in case, Linux 5.14 and ghc 8.10.4

Additional context
This may be related to #8484, which describes the even-more-confusing error you get when you think "maybe t wasn't specific enough" and try cabal v2-run exe:t as your first debugging step.

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