rules_haskell icon indicating copy to clipboard operation
rules_haskell copied to clipboard

Transitive re-exporting does not work

Open eltix opened this issue 6 years ago • 1 comments

Describe the bug

When there are at least two levels of re-exporting, the innermost modules do not get exported.

To Reproduce Consider the following example:

haskell_library(
    name = "lib",
    exports = [
        ":a",
        ":b",
        ":c",
    ],
    deps = [
        ":a",
        ":b",
        ":c",
    ],
)

haskell_library(
    name="pipeline",
    exports = [":lib"],
    deps=[
      "@hackage//:aeson",
      ":lib",
     ]

haskell_binary(
    name="exe",
    srcs=["src/Main.hs"],
    deps=[
        "@hackage//:base",
        ":pipeline",
    ],
)

The above will fail upon building with this error:

src/Main.hs:21:1: error:
    Could not load module ‘A’
    It is a member of the hidden package ‘a’.
    You can run ‘:set -package a’ to expose it.
    (Note: this unloads all the modules in the current scope.)
    Use -v to see a list of the files searched for.
   |
21 | import qualified A  as A

where A.hs is a Haskell source file of the library ":a"

Everything works fine when ":lib" is added to the deps of the haskell binary.

Expected behavior We shouldn't have to add ":lib" to the deps of the haskell binary since it's already re-exported by ":pipeline"

Environment

  • OS name + version: Ubuntu 19.10
  • Bazel version: "Build label: 0.28.0- (@non-git)"
  • Version of the rules: "23c6b64cae7db676485a1e401698520f4cdd8254"

eltix avatar Nov 14 '19 16:11 eltix

At a cursory look, fixing this will probably require tracking exports transitively here instead of just the direct exports. This should probably be done by using a depset instead of a list to track these.

aherrmann avatar Feb 21 '22 10:02 aherrmann

@prednaz was this resolved by #2125? If so, please close. :slightly_smiling_face:

aherrmann avatar Mar 13 '24 12:03 aherrmann

fixed by https://github.com/tweag/rules_haskell/pull/2125

prednaz avatar Mar 13 '24 15:03 prednaz