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

Command to print GHC_PACKAGE_PATH #4806

Closed
sgraf812 opened this issue Oct 2, 2017 · 9 comments
Closed

Command to print GHC_PACKAGE_PATH #4806

sgraf812 opened this issue Oct 2, 2017 · 9 comments

Comments

@sgraf812
Copy link
Contributor

sgraf812 commented Oct 2, 2017

There should really be a command to just print GHC_PACKAGE_PATH as set by cabal exec, like stack path --ghc-package-path. Or is there already a way to do this right now?

@phadej
Copy link
Collaborator

phadej commented Oct 2, 2017

Doens't something like

cabal exec -- sh -c 'echo $GHC_PACKAGE_PATH'

work?

@sgraf812
Copy link
Contributor Author

sgraf812 commented Oct 2, 2017

This doesn't work on Windows. Well, it works when going through stack exec --no-ghc-package-path -- cabal exec -- sh -c 'echo $GHC_PACKAGE_PATH', but not when just doing cabal exec -- sh -c 'echo $GHC_PACKAGE_PATH' through a vanilla HP installation.

@phadej
Copy link
Collaborator

phadej commented Oct 2, 2017

@sgraf812 note that (If i read code right) cabal exec doesn't always set GHC_PACKAGE_PATH, one scenario is when there is sandboxes involved (maybe stack triggers something like that in cabal, dunno).

What are you trying to do, maybe there is some other way to solve your X problem, without solving Y (= getting GHC_PACKAGE_PATH)?

@sgraf812
Copy link
Contributor Author

sgraf812 commented Oct 2, 2017

I'm basically trying to solve https://stackoverflow.com/questions/46505007/access-ghc-package-database-in-test-and-benchmark-suite in a relatively portable way.

@phadej
Copy link
Collaborator

phadej commented Oct 2, 2017

@sgraf812 one solution is to use build-type: Custom, in a way http://hackage.haskell.org/package/cabal-doctest does, so you get all needed flags.

With doctest, we have to feed doctest package-ids and package-db flags, for it to work properly. cabal-doctest "solves" that. The core problem seems similar. I'm not aware of easier, non-hacky solution. (Except adding custom code into Cabal)

@sgraf812
Copy link
Contributor Author

sgraf812 commented Oct 2, 2017

OK, thanks. I'll look into it when I prepare a release for my prototype.

@23Skidoo
Copy link
Member

#3643 is possibly related.

@gbaz
Copy link
Collaborator

gbaz commented Aug 28, 2021

possibly could be solved by #7500 ?

@jneira
Copy link
Member

jneira commented Apr 23, 2022

This doesn't work on Windows. Well, it works when going through stack exec --no-ghc-package-path -- cabal exec -- sh -c 'echo $GHC_PACKAGE_PATH', but not when just doing cabal exec -- sh -c 'echo $GHC_PACKAGE_PATH' through a vanilla HP installation.

Hi, i usually use this trick to print the environment vars set by cabal:

PS D:\dev\ws\haskell\cabal> cabal exec -- cmd
Microsoft Windows [Versión 10.0.19044.1645]
(c) Microsoft Corporation. Todos los derechos reservados.

D:\dev\ws\haskell\cabal>echo %GHC_ENVIRONMENT%
D:\dev\ws\haskell\cabal\dist-newstyle\tmp\environment.-10396\.ghc.environment.x86_64-mingw32-8.10.7

Note i am not using %GHC_PACKAGE_PATH% as nowadays cabal exec is cabal v2-exec and it seems the v2 use ghc environment files to interact with ghc instead GHC_PACKAGE_PATH. But if it was set, it would be also printed
In fact v1-commands are deprecated and v1-exec does not exist anymore in cabal-3.6.2.0

So as there was a suggestion to fix your original issue, motivation to print GHC_PACKAGE_PATH i would close this.
Feel free to reopen if you have any question or you think it should be keep alive.

@jneira jneira closed this as completed Apr 23, 2022
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