Skip to content

Split dual purpose Cabal-7136 error #9533

Open
@philderbeast

Description

Describe the bug
I find this error message confusing. It describes two situations. Could we have a specific error message for each situation instead?

There is no <pkgname>.cabal package file or cabal.project file.

To Reproduce
Perform cabal init then touch cabal.project but keep the project empty.

$ cabal build all --enable-tests --enable-benchmarks
Warning: There are no packages or optional-packages in the project
Error: [Cabal-7136]
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.

Now go to an empty directory and run the same command.

$ cabal build all --enable-tests --enable-benchmarks
Error: [Cabal-7136]
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.

Notice the difference?

- Warning: There are no packages or optional-packages in the project
Error: [Cabal-7136]
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.

Expected behavior
Error with one of these messages instead or something similar:

  1. The cabal.project file is empty. It needs to contain at least one package or optional-package.
  2. The cabal.project file contains no packages or optional-packages. At least one is needed.
  3. There is no .cabal package file. To build packages locally you'll need one and can use 'cabal init' to create a package.
  4. There are .cabal package files in child directories. Do you have a cabal.project file in another directory (preferably above) packages in your project?

System information

I have cabal-install built from source at e3fd74c on ubuntu 23.10.

$ cabal --version
cabal-install version 3.11.0.0
compiled using version 3.11.0.0 of the Cabal library

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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