Describe the bug
ghc-pkg list is not finding packages I install with cabal 3.0 and ghc 8.8.1
To Reproduce
ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.8.1
cabal --version
cabal-install version 3.0.0.0
bash-3.2$ cabal install QuickCheck
Resolving dependencies...
Up to date
Warning: You asked to install executables, but there are no executables in
target: QuickCheck. Perhaps you want to use --lib to install libraries
instead.
bash-3.2$ cabal install --lib QuickCheck
Resolving dependencies...
Up to date
bash-3.2$ ghc-pkg list|fgrep -i Quick
Expected behavior
I expect ghc-pkg list to show QuickCheck
System informataion
cabal, ghc versionsI think this is expected behaviour, at least from the cabal side of things. Version 3.0.0.0 switched to using v2-build by default so installed libraries are now registered into the "default" package environment file in .ghc/*/environments/default as well as a package-db in .cabal/store/ghc-*/package.db which GHC doesn't know about by itself.
AFAICS ghc-pkg simply doesn't have support for listing package environments which sort of kind of makes sense but also breaks this workflow. I think this should be reported as a GHC bug but I'm not sure it would even be a good idea to add pkg-env support to ghc-pkg.
cc @hvr
Thanks Daniel
I thought it might be a ghc issue but since nobody else was complaining I
assumed I must have done something wrong. I can file a ghc bug if people
want.
Cheers
George
On Mon, Oct 7, 2019 at 2:58 AM Daniel Gröber (dxld) <
[email protected]> wrote:
cc @hvr https://github.com/hvr
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/haskell/cabal/issues/6262?email_source=notifications&email_token=ABQIJ62KAVHHP7PVFRQHTB3QNLFXLA5CNFSM4I3MHL4KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEAPDLEY#issuecomment-538850707,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABQIJ6ZESTAS3OMI6YBTN6LQNLFXLANCNFSM4I3MHL4A
.
I filed a ghc bug: https://gitlab.haskell.org/ghc/ghc/issues/17341
It was closed as not a bug. I updated it with:
ok, but it is a change in behaviour from the view point of an end user.
Thanks for responding; from your response, the env file, and the doc I was able to figure out that I now need to type: "ghc-pkg list -f /Users/gcolpitts/.cabal/store/ghc-8.8.1/package.db" Not sure if this change should be in the release notes.
This feels to me like a step backwards from just typing "ghc-pkg list" as the user doesn't have to know anything about package dbs or their location. Not sure how to go about improving the current state but thanks for your help.
So I think there's two things. First a feature request for ghc-pkg that it become env file aware. This is not in scope for this tracker.
The thing in scope for this tracker is more documentation about how v2-build works in cabal 3.0, which is covered by this ticket among others: https://github.com/haskell/cabal/issues/6104
So going to close this out.
see https://gitlab.haskell.org/ghc/ghc/issues/17341 for the feature request that ghc-pkg become env file aware.
I worked around this for now by saying:
ln -s ~/.cabal/store/ghc-8.6.5/package.db ~/.ghc/x86_64-darwin-8.6.5/package.conf.d
EDIT:
Also say:
rm -r ~/.ghc/x86_64-darwin-8.6.5/environments
It seems to me that the problem is simply that there isn't a wildcard option to expose all visible packages in the database. With this, ghc-pkg wouldn't need to be environment-aware, as the default environment could just use the wildcard.
I strongly feel like this issue should not have been closed, or at least document that this is broken.
This is not a cabal issue. ghc-pkg is not a cabal tool, it is a ghc tool. the relevant open issue is on the ghc tracker, as posted above: https://gitlab.haskell.org/ghc/ghc/issues/17341
I just re-read @DanielG 's comment, saying that cabal adds the newly-installed library to the default environment, so I did some experiments and found that this is only partially true. This may be the root of the problem.
If I say cabal install xxx --lib, where xxx is a library package, then it is indeed added to the default environment. However, if I just say cabal install xxx, as is habitual, then it warns:
"Warning: You asked to install executables, but there are no executables in target: xxx. Perhaps you want to use --lib to install libraries instead." It does add the library to the package db in this case but does not add it to the default environment.
The warning message feels odd to me, as I didn't ask Cabal to install executables, I just asked it for xxx. I'd expect it to realise that the package contains only libraries and behave accordingly. So this issue feels to me like a bug, inasmuch as the behaviour I'm seeing surprises me.
That behavior has nothing to do with this ticket. That's the behavior of install under 3.0 semantics. Further, the warning seems like it explains this behavior pretty clearly.
Most helpful comment
I just re-read @DanielG 's comment, saying that cabal adds the newly-installed library to the default environment, so I did some experiments and found that this is only partially true. This may be the root of the problem.
If I say cabal install xxx --lib, where xxx is a library package, then it is indeed added to the default environment. However, if I just say cabal install xxx, as is habitual, then it warns:
"Warning: You asked to install executables, but there are no executables in target: xxx. Perhaps you want to use --lib to install libraries instead." It does add the library to the package db in this case but does not add it to the default environment.
The warning message feels odd to me, as I didn't ask Cabal to install executables, I just asked it for xxx. I'd expect it to realise that the package contains only libraries and behave accordingly. So this issue feels to me like a bug, inasmuch as the behaviour I'm seeing surprises me.