-
Notifications
You must be signed in to change notification settings - Fork 698
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
Make ghc-pkg discoverable from ghc executable #7390
Comments
Does this supersede/obsoletes #6648 or are both valuable? |
I'll try the patch out tomorrow in conjunction with the GHC patch. I also noticed that we could investigate another workaround in the following function cabal/Cabal/src/Distribution/Simple/GHC.hs Lines 267 to 278 in 4f8aeb2
What if we canonicalize first and then effectively follow the symlink if it is one... that would make us usually end up in the internal ghc directory, which should always work. No? The advantage of this would be that it's a backwards compatible fix that doesn't need a GHC patch. @rvl do you know if this could break a nix use case? |
@hasufell, that would work. On my machine
I think both |
Motivation ---------- Often times, the user facing `ghc` binary is symlinked by other forces, such as the package manager, tooling like ghcup etc. As such, the naming convention (version suffix in particular) may not align with the assumptions made in Cabal and it may find an incorrect ghc-pkg. See: - haskell#7390 - https://gitlab.haskell.org/ghc/ghc/-/issues/18807 - https://gitlab.haskell.org/haskell/ghcup-hs/-/issues/73 Solution -------- Guessing the ghc-pkg path is already a hack and will be solved more appropriately in the future, see - https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4214 - https://gitlab.haskell.org/ghc/ghc/-/snippets/2710 These patches will solve the issue for future GHC versions. As such, this patch provides a workaround for older, already existing GHC versions by first always following the symbolic link of the ghc binary (if it is one) and prefering its target directory as the guess lookup location. Rationale --------- The canonicalized path of the ghc binary usually points to the bin/ directory unpacked from a bindist, which is less likely to be tampered with by distributions and tools. As such, prefering the canoncialized path should get us more robust results.
Motivation ---------- Often times, the user facing `ghc` binary is symlinked by other forces, such as the package manager, tooling like ghcup etc. As such, the naming convention (version suffix in particular) may not align with the assumptions made in Cabal and it may find an incorrect ghc-pkg. See: - haskell#7390 - https://gitlab.haskell.org/ghc/ghc/-/issues/18807 - https://gitlab.haskell.org/haskell/ghcup-hs/-/issues/73 Solution -------- Guessing the ghc-pkg path is already a hack and will be solved more appropriately in the future, see - https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4214 - https://gitlab.haskell.org/ghc/ghc/-/snippets/2710 These patches will solve the issue for future GHC versions. As such, this patch provides a workaround for older, already existing GHC versions by first always following the symbolic link of the ghc binary (if it is one) and prefering its target directory as the guess lookup location. Rationale --------- The canonicalized path of the ghc binary usually points to the bin/ directory unpacked from a bindist, which is less likely to be tampered with by distributions and tools. As such, prefering the canoncialized path should get us more robust results.
Motivation ---------- Often times, the user facing `ghc` binary is symlinked by other forces, such as the package manager, tooling like ghcup etc. As such, the naming convention (version suffix in particular) may not align with the assumptions made in Cabal and it may find an incorrect ghc-pkg. See: - haskell#7390 - https://gitlab.haskell.org/ghc/ghc/-/issues/18807 - https://gitlab.haskell.org/haskell/ghcup-hs/-/issues/73 Solution -------- Guessing the ghc-pkg path is already a hack and will be solved more appropriately in the future, see - https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4214 - https://gitlab.haskell.org/ghc/ghc/-/snippets/2710 These patches will solve the issue for future GHC versions. As such, this patch provides a workaround for older, already existing GHC versions by first always following the symbolic link of the ghc binary (if it is one) and prefering its target directory as the guess lookup location. Rationale --------- The canonicalized path of the ghc binary usually points to the bin/ directory unpacked from a bindist, which is less likely to be tampered with by distributions and tools. As such, prefering the canoncialized path should get us more robust results.
Motivation ---------- Often times, the user facing `ghc` binary is symlinked by other forces, such as the package manager, tooling like ghcup etc. As such, the naming convention (version suffix in particular) may not align with the assumptions made in Cabal and it may find an incorrect ghc-pkg. See: - #7390 - https://gitlab.haskell.org/ghc/ghc/-/issues/18807 - https://gitlab.haskell.org/haskell/ghcup-hs/-/issues/73 Solution -------- Guessing the ghc-pkg path is already a hack and will be solved more appropriately in the future, see - https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4214 - https://gitlab.haskell.org/ghc/ghc/-/snippets/2710 These patches will solve the issue for future GHC versions. As such, this patch provides a workaround for older, already existing GHC versions by first always following the symbolic link of the ghc binary (if it is one) and prefering its target directory as the guess lookup location. Rationale --------- The canonicalized path of the ghc binary usually points to the bin/ directory unpacked from a bindist, which is less likely to be tampered with by distributions and tools. As such, prefering the canoncialized path should get us more robust results. (cherry picked from commit f78d2aa)
How can we help to move this forward? @bgamari, are your patches alive? |
Just go out of curiosity, in what cases ghc-pkg path is not the the same as ghc plus -pkg? |
Yes, one could look for suffix etc, but that is a hack (heuristic in OP) which has shown to be unreliable. |
FWIW, |
Thank you @phadej |
Describe the bug
Currently there is no robust way to locate the
ghc-pkg
executable corresponding to a particular compiler. For this reason, Cabal currently implements a variety of heuristics to do the same. However, these can end up failing, in particular when the executable name is version-suffixed.@hasufell and I discussed this some months ago after a
ghc-up
user encountered this problem, which resulted in GHC #18807. To address this I proposed thatghc --info
should report the path to the correspondingghc-pkg
executable. This solves the problem nicely since Cabal already must query--info
when configuring a package.I have put together a very straightforward GHC implementation as !4214. I have also written a quick patch implementing the Cabal support.
My sense is that this is the right solution to the problem. However, I'm also happy to hear alternatives. If there are no objections, I will backport to 8.10.5, 9.0.2, and 9.2.1 such that future users won't encounter this issue in the future.
The text was updated successfully, but these errors were encountered: