Home > other >  Problem with loading module ‘Distribution.Simple’
Problem with loading module ‘Distribution.Simple’

Time:02-14

I was trying to build one new project in Haskell (GHC version 8.10.4, stack version 2.7.3, cabal version 3.6.2.0) using stack, but at the time of running the command stack setup I (surprisingly) got the following error:

Setup.hs:2:1: error:
    Could not load module ‘Distribution.Simple’
    It is a member of the hidden package ‘Cabal-3.2.1.0’.
    You can run ‘:set -package Cabal’ 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.
  |
2 | import Distribution.Simple
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^

Also, it is worth noting that I was trying to look for different solutions on the Internet, but didn't find the working one for me. The general idea was to explicitly add Cabal into the package.yaml file here:

library:
  source-dirs: src
  dependencies:
    - Cabal

But that didn't save my situation. I was able to build the project without that step (well, just skipped that part), but I was interested to solve the issue.

Moreover, when I was trying to build Haskell package timeit (as an example, using the command line), there was the same error at the time of executing runhaskell Setup.hs configure.

Interestingly, I didn't have this problem before (probably, it appeared after I updated GHC).

Does anybody know any ways of how to deal with such issue? Is there any way probably to reinstall the GHC, or cabal, or stack (if it helps)? Would be glad to see any comments and solutions.

CodePudding user response:

I had the same issue. Deleting the files

~/.ghc/*/environments/default

(or the whole folder .ghc) solved the stack setup problem.

It seems that they were somehow interacting with stack's operations.

CodePudding user response:

Instead of deleting the

~/.ghc/*/environments/default

file, just add the Cabal package to it, including version number, which you can find if you run the command:

ghc-pkg list
  • Related