Unhelpful error if user forgets `package` in cabal.project file
- Dominant language
- Haskell
- Stars
- 1.7k
- Forks
- 750
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 28
Description
**Describe the bug**
A new user creates a package with `mkdir mypackage; cabal init`. They need to add a package from github, perhaps google it, and only copy paste part of the snippet to do so.
Instead of:
```
source-repository-package
type: git
location: git://github.com/[repo owner]/[the repo i want to include as dependency].git
package: .
```
They miss the `package` piece in the `cabal.project` file because they are new to Haskell and just want to build a package (or are tired and trying to hack together a minimal reproduction with cabal without having used it in ages :smile: ).
They then go to build their project and get the confusing error:
```
~/myproj $ cabal v2-build
cabal: 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.
```
**Expected behavior**
An error if a missing `package` line in a cabal.project never makes sense or warning something like:
```diff
~/myproj $ cabal v2-build
+ cabal: warning `cabal.project` does not specify a `project` and this could cause confusing errors. Did you mean to do that?
cabal: 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.
```
**System information**
- Operating system: nixos
- `cabal`, `ghc` versions: ghc 8.10.4/cabal 3.0.0.0
Contributor guide
Assessment
This issue has not been assessed yet.