Skip to content

Split dual purpose Cabal-7136 error #9533

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
philderbeast opened this issue Dec 17, 2023 · 2 comments
Open

Split dual purpose Cabal-7136 error #9533

philderbeast opened this issue Dec 17, 2023 · 2 comments
Labels
attention: pr-welcome re: error-message Concerning error messages delivered to the user re: user experience User experience (UX) issue type: enhancement

Comments

@philderbeast
Copy link
Collaborator

philderbeast commented Dec 17, 2023

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
@philderbeast philderbeast added type: bug needs triage re: error-message Concerning error messages delivered to the user labels Dec 17, 2023
@Mikolaj
Copy link
Member

Mikolaj commented Dec 19, 2023

PR welcome. While implementing, the brave dev may find that is some cases it's not possible to easily distinguish in what scenario we are, and then we'd be back to the drawing board. But if not, this looks to me like an obvious win.

@philderbeast
Copy link
Collaborator Author

Related to #9353.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
attention: pr-welcome re: error-message Concerning error messages delivered to the user re: user experience User experience (UX) issue type: enhancement
Projects
None yet
Development

No branches or pull requests

3 participants