Skip to content
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

Improve error message when multiple .cabal files are in the same directory #7395

Open
fendor opened this issue May 15, 2021 · 6 comments · May be fixed by #7396
Open

Improve error message when multiple .cabal files are in the same directory #7395

fendor opened this issue May 15, 2021 · 6 comments · May be fixed by #7396
Assignees

Comments

@fendor
Copy link
Collaborator

fendor commented May 15, 2021

Describe the bug
Improve error message when multiple .cabal files are in the same directory

To Reproduce
Have two .cabal files in the sme directory. Example

$ cabal init -n some-name
$ cp some-name.cabal some-name2.cabal
$ cabal v2-build
Resolving dependencies...
TODO: add support for multiple packages in a directory.  Got
some-name-0.1.0.0
some-name2-0.1.0.0

CallStack (from HasCallStack):
  error, called at ./Distribution/Client/ProjectOrchestration.hs:552:9 in main:Distribution.Client.ProjectOrchestration

Expected behavior
No callstack should be shown, nor a big TODO.

System information

  • cabal 3.4 installed via ghcup
@DanielG
Copy link
Collaborator

DanielG commented May 15, 2021

Related: #6197

@fendor fendor self-assigned this May 15, 2021
@andreasabel andreasabel added re: error-message Concerning error messages delivered to the user re: project-file Concerning cabal.project files type: bug weird bug award labels Nov 13, 2021
@andreasabel
Copy link
Member

andreasabel commented Nov 13, 2021

The error is especially unhelpful if there is only one package:

$ cabal build
TODO: add support for multiple packages in a directory.  Got
BNFC-2.9.4
BNFC-2.9.4

CallStack (from HasCallStack):
  error, called at src/Distribution/Client/ProjectOrchestration.hs:579:9 in cabal-install-3.7.0.0-inplace:Distribution.Client.ProjectOrchestration

$  find . -name "*.cabal"
./BNFC.cabal

$ cat cabal.project.local
packages: BNFC.cabal

package *
  ghc-options: -fwrite-ide-info

Removing cabal.project.local makes the error go away. What is going on here?

This is a reproducer (for at least 3.0, 3.2, 3.4, 3.6.2, master):

#!/bin/sh

cd $(mktemp -d)
${CABAL:-cabal} init -n --exe --package-name=IExistOnlyOnce
cat > cabal.project.local <<EOF
packages: IExistOnlyOnce.cabal
package *
  ghc-options: -Wall
EOF
${CABAL:-cabal} build

Error:

...
TODO: add support for multiple packages in a directory.  Got
IExistOnlyOnce-0.1.0.0
IExistOnlyOnce-0.1.0.0
...

Not reproducible in 2.4.1.

@fendor
Copy link
Collaborator Author

fendor commented Nov 13, 2021

The issue posted before #6197 also mentions that cabal.project.local behaves weirdly.

fendor added a commit to fendor/cabal that referenced this issue Nov 13, 2021
fendor added a commit to fendor/cabal that referenced this issue Nov 13, 2021
fendor added a commit to fendor/cabal that referenced this issue Feb 12, 2022
fendor added a commit to fendor/cabal that referenced this issue Feb 13, 2022
fendor added a commit to fendor/cabal that referenced this issue Feb 13, 2022
fendor added a commit to fendor/cabal that referenced this issue Feb 19, 2022
fendor added a commit to fendor/cabal that referenced this issue Feb 23, 2022
fendor added a commit to fendor/cabal that referenced this issue Feb 23, 2022
fendor added a commit to fendor/cabal that referenced this issue Feb 24, 2022
fendor added a commit to fendor/cabal that referenced this issue Feb 24, 2022
fendor added a commit to fendor/cabal that referenced this issue Mar 5, 2022
fendor added a commit to fendor/cabal that referenced this issue Jul 9, 2022
@lf-
Copy link
Collaborator

lf- commented Sep 25, 2022

Oh, there's another fun way to cause this bug: do this:

cabal.project:

packages: .

cabal.project.local:

packages: .

Surprisingly, I've hit this multiple times by accident.

@fendor
Copy link
Collaborator Author

fendor commented Sep 25, 2022

The whole approach how cabal.project files are tracked and handled need to be redesigned with good error messages in mind. The PR #7396 only fixes a single symptom, I believe we need to change the Semigroup instance of project files to include more provenance information.

Would love to work on it, but I am a little overextended at the moment. If someone else wants to work on it, I'd be very happy to explain my thoughts in more detail and pair a bit to show what I think needs to be fixed.

@Mikolaj
Copy link
Member

Mikolaj commented Sep 28, 2022

Oh, there's another fun way to cause this bug

Oh yes, I got stumped by this a couple of ears ago. Perhaps in a variant, where both places have ../.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants