cabal icon indicating copy to clipboard operation
cabal copied to clipboard

"Error: cabal: There is no <pkgname>.cabal package file or cabal.project file." in directory with .cabal file

Open juhp opened this issue 2 years ago • 2 comments

Describe the bug cabal build gives a very confusing error message in a (unknown) package subdirectory under a cabal.project.

To Reproduce

  1. have a project with cabal.project
  2. in a tmp/ subdir unpack a cabal package
  3. try to build said package:
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.

but there is a .cabal file right there!

Expected behavior Package in unrelated subdir to build normally. Also complaining there is no .cabal file is rather confusing.

System information

  • Operating system: Fedora Linux
  • cabal-3.8+, ghc-9.4

Additional context Currently used by hkgr to do pristine sanity builds from tarball before publishing to Hackage.

Related discussion: #8519

juhp avatar Oct 19 '23 16:10 juhp

I would like to propose a better behaviour: to ignore cabal.project once it is established that the immediate .cabal file is not part of that project.

juhp avatar Oct 19 '23 16:10 juhp

I like this proposal -- I've run into this issue before, and I can't think of a case where this would be problematic. It might be worth printing a notification when this situation arises however, just to avoid potential confusion.

gbaz avatar Oct 19 '23 18:10 gbaz