Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

GHC -package <pkg> does not expose an installed package listed by ghc-pkg list <pkg> #6616

Open
tonicebrian opened this issue Jun 27, 2024 · 5 comments

Comments

@tonicebrian
Copy link

General summary/comments (optional)

Stack used as a script fails to find pandoc library although it has been downloaded and compiled.

Steps to reproduce

Just run this script:

#!/usr/bin/env stack
{- stack script --resolver lts-21.25 --package pandoc -}

import Prelude
import Text.Pandoc

main :: IO ()
main = putStrLn "Pandoc detected"

Expected

I would expect the "Pandoc detected" printed in screen

Actual

The script fails to compile with:

/home/cebrian/borralodedentro/example.hs:5:1: error:
    Could not load module ‘Text.Pandoc’
    It is a member of the hidden package ‘pandoc-3.0.1’.
    You can run ‘:set -package pandoc’ to expose it.
    (Note: this unloads all the modules in the current scope.)
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
  |
5 | import Text.Pandoc
  | ^^^^^^^^^^^^^^^^^^

Stack version

❯ stack --version
Version 2.15.7, Git revision 75bb479f04755c1daf91ec8f445e17e2ba2ab7a3 x86_64 hpack-0.36.0

Method of installation

  • Via GHCup

Platform

Linux Ubuntu 22.04

@philderbeast
Copy link
Contributor

This doesn't happen with the latest resolver.

   #!/usr/bin/env stack
-  {- stack script --resolver lts-21.25 --package pandoc -}
+  {- stack script --resolver nightly-2024-06-22 --package pandoc -}

   import Prelude
   import Text.Pandoc

   main :: IO ()
   main = putStrLn "Pandoc detected"
$ ./example.hs
Pandoc detected

@tonicebrian
Copy link
Author

For me it doesn't work neither with lts-21.25 nor lts-22.26. I cannot go for nightly because that would involve changing the GHC compiler. Should I file an issue in LTS?

@mpilgrem
Copy link
Member

@tonicebrian, thanks for reporting. I'm looking into this.

@mpilgrem
Copy link
Member

mpilgrem commented Jun 29, 2024

Related discussion: https://discourse.haskell.org/t/stack-script-fails-to-find-pandoc/9817/9

@tonicebrian, I think this is - at least, in part - an issue with GHC's runghc, and I have opened: https://gitlab.haskell.org/ghc/ghc/-/issues/25035.

My reasoning is that (on Windows):

❯ stack --snapshot lts-21.21 exec -- runghc -hide-all-packages -package=base -package=pandoc example1.hs

example1.hs:6:1: error:
    Could not load module ‘Text.Pandoc’
    It is a member of the hidden package ‘pandoc-3.0.1’.
    You can run ‘:set -package pandoc’ to expose it.
    (Note: this unloads all the modules in the current scope.)
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
  |
6 | import Text.Pandoc
  | ^^^^^^^^^^^^^^^^^^

shoud not be a possible output of runghc. The very purpose of -package=pandoc is to expose pandoc.

(This is not Linux-specific but, oddly, GHC 9.4.7 works on Linux, fails on Windows and GHC 9.4.8 fails on Linux, works on Windows - all with pandoc-3.0.1.)

@mpilgrem
Copy link
Member

mpilgrem commented Jul 5, 2024

The cause of this has been identified, as now discussed at:

I would characterise it as a 'GHC project' bug. I would not expect GHC's -package <pkg> option to be able to expose an installed package that was not listed by ghc-pkg list <pkg> and not to expose the sole installed package listed by ghc-pkg list <pkg>.

@mpilgrem mpilgrem changed the title Stack script fails to use Pandoc library GHC -package <pkg> does not expose a installed package listed by ghc-pkg list <pkg> Jul 5, 2024
@mpilgrem mpilgrem changed the title GHC -package <pkg> does not expose a installed package listed by ghc-pkg list <pkg> GHC -package <pkg> does not expose an installed package listed by ghc-pkg list <pkg> Jul 5, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

3 participants