haskell / docker-haskell

MIT License
63 stars 37 forks source link

"RUN cabal install --only-dependencies -j4" fails with "Could not find module: <lib_module> with any suffix" #26

Closed runeksvendsen closed 3 years ago

runeksvendsen commented 3 years ago

In the How to use this image section here, the following Dockerfile is given as an example:

FROM haskell:8

WORKDIR /opt/example

RUN cabal update

COPY ./example.cabal /opt/example/example.cabal

RUN cabal install --only-dependencies -j4

COPY . /opt/example
RUN cabal install

CMD ["example"]

However, when I try to build this image and it reaches the command RUN cabal install --only-dependencies -j4 cabal fails with an error saying "Could not find module: x with any suffix", where x is the first module listed in my cabal file under library -> exposed-modules.

So it looks like Cabal needs the source code files of my project to be present when running --only-dependencies and I don't understand why.

For reference, I'm using the haskell:8.8.4-buster image.

lukel97 commented 3 years ago

Using RUN cabal build --only-dependencies -j4 worked around this for me

runeksvendsen commented 3 years ago

Thank you @bubba. I can confirm that this works for me as well.

AlistairB commented 3 years ago

Should be fixed in the docs now.