Split dual purpose Cabal-7136 error
- Dominant language
- Haskell
- Stars
- 1.7k
- Forks
- 750
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 28
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 .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 .cabal package file or cabal.project file. To build
packages locally you need at minimum a .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 .cabal package file or cabal.project file. To build
packages locally you need at minimum a .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?
```diff
- Warning: There are no packages or optional-packages in the project
Error: [Cabal-7136]
There is no .cabal package file or cabal.project file. To build
packages locally you need at minimum a .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 e3fd74c2cb3c933fcbcee54b867961b86c1c6d72 on ubuntu 23.10.
```
$ cabal --version
cabal-install version 3.11.0.0
compiled using version 3.11.0.0 of the Cabal library
```
Contributor guide
Assessment
This issue has not been assessed yet.