Skip to content

Cabal install does not find locally installed dependency ("unknown package") #8714

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

Open
danse opened this issue Jan 31, 2023 · 8 comments
Open

Comments

@danse
Copy link

danse commented Jan 31, 2023

Describe the bug
I have package b depending on a. a is locally installed but when trying to build b, the dependency is not found. The error looks like:

Error: cabal: Could not resolve dependencies:
[__0] trying: b-0.1.0.0 (user goal)
[__1] unknown package: a (dependency of b)
[__1] fail (backjumping, conflict set: b, a)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: b, a

To Reproduce
Move to a, run cabal install, the installation succeeds. Now move to b depending on a, run cabal install, the installation fails with the error mentioned above. These are v2- commands.

Expected behavior
After installing a, i expected it to be locally visible for resolving dependencies.

System information

  • Ubuntu 20.04.5 LTS
  • cabal 3.8.1.0, ghc 8.6.5

Additional context
Executables provided by a are accessible and the library it provides gets correctly imported into ghci

@andreasabel
Copy link
Member

These are v2- commands.

In general, v2 commands do not honor packages installed locally. If you want your workflow, you have to use v1 commands.

One way to make local packages available for v2 is to add your own local package index:

@gbaz
Copy link
Collaborator

gbaz commented Feb 3, 2023

This may be resolved in master by #8607 (comment)

@danse
Copy link
Author

danse commented Feb 4, 2023

Thanks @andreasabel, probably i have a simplistic mental model of caching in cabal. I thought that once installed, packages kept no track of where they came from.

The doc you referenced seems a great solution to use version two for this use case. I tried adding:

repository a
        url: file+noindex:///home/name/a/dist-newstyle/sdist/

To b.cabal, since install leaves a .tar.gz for a in that dir, but it still does not find the package.

Thanks @gbaz for the reference to what is being merged. Is there a way to figure out which release will include those improvements, so that i can test again?

@andreasabel
Copy link
Member

@danse worte

adding ... To b.cabal

Ah, no, this has to go into cabal.project which you can put besides b.cabal.
.cabal files are for uploading to hackage, so they cannot mention things local to your machine/configuration.

@danse
Copy link
Author

danse commented Feb 5, 2023

whoops, i thought that was the section about .cabal configuration. This works perfectly now, i just added a packages: b.cabal to start the cabal.project. Thanks @andreasabel!

@andreasabel
Copy link
Member

Yes, somehow the documentation should in section https://cabal.readthedocs.io/en/latest/config.html#repository-specification state explicitly that one can also specify repositories in the cabal.project file.

Also, information about repositories should be referenced from https://cabal.readthedocs.io/en/latest/cabal-project.html# e.g. in https://cabal.readthedocs.io/en/latest/cabal-project.html#cfg-field-active-repositories or more centrally.

@ulysses4ever
Copy link
Collaborator

ulysses4ever commented Feb 5, 2023

state explicitly that one can also specify repositories in the cabal.project file.

Sounds like an instance of #6319.

@josephcsible
Copy link

For reference, I asked this SO question a while back about how to do this: How do I get cabal to use a local version of a package as a dependency for a Hackage package?

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

5 participants