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

Error message for missing package list is unclear when looking for build-tool-depends #7197

Open
roberth opened this issue Dec 15, 2020 · 4 comments

Comments

@roberth
Copy link

roberth commented Dec 15, 2020

Describe the bug

When the package list is missing, build-tool-depends causes a cryptic error message.

cc @chuahou

To Reproduce
Steps to reproduce the behavior:

See https://stackoverflow.com/a/65287190/428586

$ rm -rf ~/.cabal

$ cabal v2-build
[... omitted ...]
[__0] trying: aoc-0.1.0.0 (user goal)
[__1] unknown package: aoc:happy:exe.happy (dependency of aoc)
[__1] fail (backjumping, conflict set: aoc, aoc:happy:exe.happy)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: aoc, aoc:happy:exe.happy

$ cabal update
Downloading the latest package list from hackage.haskell.org

$ cabal v2-build
Resolving dependencies...
Build profile: -w ghc-8.10.2 -O1
In order, the following will be built (use -v for more details):
 - alex-3.2.6 (exe:alex) (requires download & build)
 - happy-1.20.0 (exe:happy) (requires download & build)
 - aoc-0.1.0.0 (lib) (configuration changed)
 - aoc-0.1.0.0 (exe:aoc) (dependency rebuilt)
Downloading  happy-1.20.0
[... omitted ...]
Configuring library for aoc-0.1.0.0..
Preprocessing library for aoc-0.1.0.0..
Building library for aoc-0.1.0.0..
[... omitted ...]

Please use version-prefixed commands (e.g. v2-build or v1-build) to avoid ambiguity.

Expected behavior

A clear error message indicating that the package list wasn't present on the system.
Perhaps it could be downloaded automatically.

System information

  • Operating system
  • cabal, ghc versions

Additional context
Add any other context about the problem here.

@phadej
Copy link
Collaborator

phadej commented Dec 15, 2020

If you read the output properly:

% cabal build --dry
Warning: The package list for 'hackage.haskell.org' does not exist. Run 'cabal
update' to download it.RemoteRepo {remoteRepoName = RepoName
"hackage.haskell.org", remoteRepoURI = http://hackage.haskell.org/,
remoteRepoSecure = Just True, remoteRepoRootKeys =
["fe331502606802feac15e514d9b9ea83fee8b6ffef71335479a2e68d84adc6b0","1ea9ba32c526d1cc91ab5e5bd364ec5e9e8cb67179a471872f6e26f0ae773d42","2c6c3627bd6c982990239487f1abd02e08a02e6cf16edb105a8012d444d870c3","0a5c7ea47cd1b15f01f5f51a33adda7e655bc0f0b0615baa8e271f4c3351e21d","51f0161b906011b52c6613376b1ae937670da69322113a246a09f807c62f6921"],
remoteRepoKeyThreshold = 3, remoteRepoShouldTryHttps = True}
Resolving dependencies...
cabal: Could not resolve dependencies:
[__0] trying: splitmix-tools-0 (user goal)
[__1] unknown package: vector (dependency of splitmix-tools)
[__1] fail (backjumping, conflict set: splitmix-tools, vector)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: splitmix-tools, vector

it literally starts with

Warning: The package list for 'hackage.haskell.org' does not exist. Run 'cabal
update' to download it.

This is no bug.

Whether to download automatically, I have no opinion. In cabal-install-3.4 there is a way to disable use of configured package repositories (previously the only way was to alter the actual config), so enabling download when repository doesn't exist at all should be fine.

@roberth
Copy link
Author

roberth commented Dec 15, 2020

I agree that it's not a bug. It's "just" bad user experience.

Maybe I got numbed by (other) verbose build logs or may I got demotivated by the weird "show RemoteRepo" logging.
Either way, it seems like a bad idea to require extra steps for something that 99% of users need to do anyway.

Possible actions

  • remove "show RemoteRepo" logging. Users may skip past such logs. (this might have been a patched cabal? idk)
  • add some logic to the final message specifically for this case (no package list)
  • download the package list automatically. Not sure if that's entirely great, because new users will have to learn the relevance of cabal update at some point.

@chuahou
Copy link

chuahou commented Dec 15, 2020

Thank you @roberth for bringing this here from Stack Overflow.

I personally feel this isn't a cabal problem, but rather a nix problem, though. I doubt anyone using cabal by itself without nix would try to pull dependencies without cabal update, and the package list warning is indeed front and centre at the top as @phadej mentioned.

The only reason I ignored that is because I would have liked to use nix to provide those dependencies to cabal, rather than pull from Hackage—this had been working for build-depends, and nix-build manages to do this properly even for build-tool-depends, but only nix-shell seems to have this problem.

Hence, it seems to me that it's likely to be an issue with nix-shell's provision of dependencies to cabal.


Edit: @phadej's errors appearing for build-depends as well is because I hadn't had shell.nix set up correctly in the reproduce environment previously. It has now been rectified.

@ScottFreeCode
Copy link

About the nix-shell version of this problem, where the error occurs even if the tools are provided, I have a straightforward reproduction here: https://gist.github.com/ScottFreeCode/c1adb5681c5b61c61373615f63a4a7d2

And I've collected GitHub issues relating to this problem here: https://gist.github.com/ScottFreeCode/ef9f254e2dd91544bba4a068852fc81f

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

No branches or pull requests

4 participants