haskell / cabal

Official upstream development repository for Cabal and cabal-install
https://haskell.org/cabal
Other
1.62k stars 697 forks source link

`cabal install` prints unhelpful error when .cabal filename does not match the package name #7322

Open falsifian opened 3 years ago

falsifian commented 3 years ago

Describe the bug

In a project where the .cabal file has underscores in the name, cabal install fails with an unhelpful error message:

dieVerbatim: user error (cabal: Package .cabal file not found in the tarball:
/tmp/cabal-install.-42328/dist-newstyle/tmp/src-42328/note-graph-0.0.0.0/note-graph.cabal
)

After much head-scratching, I realized the problem was I needed to rename note_graph.cabal to note-graph.cabal.

To Reproduce Steps to reproduce the behavior:

executable x default-language: Haskell2010 build-depends: base main-is: Main.hs


* Put something in `Main.hs`.
* `cabal v2-install .:x`

**Expected behavior**

One of the following would be preferrable:
* The installation works.
* Cabal prints an error like `Your .cabal file should not have underscores in the name.`

**System information**
 OpenBSD current

I've got custom-built `ghc` and `cabal-install` ports; let me know if you'd like me to retry with an unmodified install.

```falsifian moth d $ ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.6.4
falsifian moth d $ cabal --version
cabal-install version 3.4.0.0
compiled using version 3.4.0.0 of the Cabal library```
jneira commented 3 years ago

@falsifian thanks for reporting the error which i can reproduce with last cabal-3.4.0.0 Points to consider:

PS D:\dev\ws\haskell\cabal-test> cabal check
Warning: The filename .\cabal_test.cabal does not match package name
(expected: cabal-test.cabal)
Warning: Hackage would reject this package.

So we could do:

Imo the build and install behaviour should be coherent and throw an error, but if it is already a warning is cause someone would be using .cabal names different from package names locally (???). So i would vote for 2, although 3 will be easier to implement i guess

falsifian commented 3 years ago

@jneira Thanks for the analysis. I don't have strong opinions or intimate knowledge of cabal, so I'll leave the discussion to others here and in #6299. I've learned the lesson already, so it's not a problem for me unless I forget :)

jneira commented 3 years ago

As a easier to do improvement, we could improve the actual error message, without touching actual semantics