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

"could not load module" errors at startup #130

Closed
simonmichael opened this issue Jun 23, 2020 · 11 comments · Fixed by #687
Closed

"could not load module" errors at startup #130

simonmichael opened this issue Jun 23, 2020 · 11 comments · Fixed by #687

Comments

@simonmichael
Copy link

Thank you, this is awesome!

But I hit trouble while following correct (I believe) install procedure, on a mac:

...
GHCi, version 8.8.3: https://www.haskell.org/ghc/  :? for help
Loaded package environment from /Users/simon/.ghc/x86_64-darwin-8.8.3/environments/default
Warning: -debug, -threaded and -ticky are ignored by GHCi
package flags have changed, resetting and loading new packages...
package flags have changed, resetting and loading new packages...
Loaded GHCi configuration from /Users/simon/src/blog/.ghci
Loaded GHCi configuration from /Users/simon/.ghci
Prelude> package flags have changed, resetting and loading new packages...
package flags have changed, resetting and loading new packages...

<no location info>: error:
    Could not load module ‘ClassyPrelude’
    It is a member of the hidden package ‘classy-prelude-1.5.0’.
    You can run ‘:set -package classy-prelude’ to expose it.
    (Note: this unloads all the modules in the current scope.)
Prelude> Prelude> [1 of 6] Compiling Application.Helper.Controller ( Application/Helper/Controller.hs, interpreted )
[2 of 6] Compiling Config           ( Config/Config.hs, interpreted )

[3 of 6] Compiling Generated.Types  ( build/Generated/Types.hs, interpreted )
build/Generated/Types.hs:7:1: error:
    Could not load module ‘CorePrelude’
    It is a member of the hidden package ‘basic-prelude-0.7.0’.
    You can run ‘:set -package basic-prelude’ to expose it.
    (Note: this unloads all the modules in the current scope.)
Failed, two modules loaded.
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
  |
7 | import CorePrelude hiding (id) 
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
@simonmichael
Copy link
Author

Worked around by adding to build/ihp-lib/applicationGhciConfig:

:set -package basic-prelude
:set -package classy-prelude
:set -package data-default
:set -package postgresql-simple
:set -package uuid

@mpscholten
Copy link
Member

Hey, thanks for reporting! :)

Can you quickly run these commands and let me know the output:

direnv status
echo $PATH
which ghci

@simonmichael
Copy link
Author

Hi @mpscholten,

~/src/blog$ direnv status
direnv exec path /usr/local/bin/direnv
DIRENV_CONFIG /Users/simon/.config/direnv
bash_path /nix/store/zmpgvfkx9mfi06g5rlv5c8v6q6hqwx72-bash-interactive-4.4-p23/bin/bash
disable_stdin false
warn_timeout 5s
whitelist.prefix []
whitelist.exact map[]
Loaded RC path /Users/simon/src/blog/.envrc
Loaded watch: ".envrc" - 2020-06-23T15:41:51-07:00
Loaded watch: "../../.local/share/direnv/allow/34a881c7d948798b7a06faa8e3863190df869949f26cb94230bb314de0cb7dac" - 2020-06-23T16:38:04-07:00
Loaded RC allowed false
Loaded RC allowPath 
Found RC path /Users/simon/src/blog/.envrc
Found watch: ".envrc" - 2020-06-23T15:41:51-07:00
Found watch: "../../.local/share/direnv/allow/34a881c7d948798b7a06faa8e3863190df869949f26cb94230bb314de0cb7dac" - 2020-06-23T16:38:04-07:00
Found RC allowed true
Found RC allowPath /Users/simon/.local/share/direnv/allow/34a881c7d948798b7a06faa8e3863190df869949f26cb94230bb314de0cb7dac
~/src/blog$ echo $PATH  # formatted
/nix/store/zmpgvfkx9mfi06g5rlv5c8v6q6hqwx72-bash-interactive-4.4-p23/bin:
/nix/store/a7115wy8h6vqs70cip8hz4kn9vgrra8c-clang-wrapper-7.1.0/bin:
/nix/store/bm99isa04nyazf0pkpj6hiszw3ydf4n0-clang-7.1.0/bin:
/nix/store/i5sd4dd4zi9czzzm404z7v3x87awmb2h-coreutils-8.31/bin:
/nix/store/w8801pa6qpfw35xlad7d7p8vzpcyhzxy-cctools-binutils-darwin-wrapper-927.0.2/bin:
/nix/store/amsm28x2hnsgp8c0nm4glkjc2gw2l9kw-cctools-binutils-darwin-927.0.2/bin:
/nix/store/i5sd4dd4zi9czzzm404z7v3x87awmb2h-coreutils-8.31/bin:
/nix/store/pmha15mrxcnfk19v3wxjh2mhmglvkvw3-ghc-8.8.3-with-packages/bin:
/nix/store/33z818hfh58m8z22cqdyrn9cnwqj8996-postgresql-11.7/bin:
/nix/store/3wiasc9rkx49pijdb85kkys3plhcixdb-ncurses-6.1-20190112/bin:
/nix/store/m3yqw7xcmhvd0cmm3jh3b469kxf3yhfp-libiconv-osx-10.12.6/bin:
/nix/store/i5sd4dd4zi9czzzm404z7v3x87awmb2h-coreutils-8.31/bin:
/nix/store/s3m9n5xbymcnhd7896vj0lrs7rvrh03f-findutils-4.7.0/bin:
/nix/store/98v6r49f77kl8nwbhfqw0l6rkmbblrs1-diffutils-3.7/bin:
/nix/store/sa6fv5wih2dzcv7m3bjsygbg0qw9dljv-gnused-4.8/bin:
/nix/store/7y44qln14q90mzpgqx6hsxq76kx7wcmj-gnugrep-3.4/bin:
/nix/store/7z56sjf5ikbza8avz727bszlsqw34v10-gawk-5.0.1/bin:
/nix/store/nba5nrs0whxpywc075lkdqr1dwivwari-gnutar-1.32/bin:
/nix/store/y6pl3v2jz9n4gym8kbfh1hgcacp7y7m6-gzip-1.10/bin:
/nix/store/bxf3ybqm1pczf74v2l49frrh69wgiaq2-bzip2-1.0.6.0.1-bin/bin:
/nix/store/cq1syjzm684wnman60haj44kbsi8jbvh-gnumake-4.2.1/bin:
/nix/store/vkrcf5jchyibdxwrgwcifxp2digqshdy-bash-4.4-p23/bin:
/nix/store/kc06f24l2gplhx9si8nj9hncl0964rg3-patch-2.7.6/bin:
/nix/store/i6xwa86h97wadzz26ycqz1ibh7sp88v5-xz-5.2.4-bin/bin:
/Users/simon/.nix-profile/bin:
/usr/local/opt/grep/libexec/gnubin:
/usr/local/opt/m4/bin:
/Users/simon/.nix-profile/bin:
/Users/simon/bin.local:
/Users/simon/bin:
/Users/simon/src/hledger/bin:
/Users/simon/src/hledger/bin/old:
/Users/simon/.local/bin:
/Users/simon/.cabal/bin:
/usr/local/bin:
/usr/local/sbin:
/opt/local/bin:
/opt/local/sbin:
/usr/bin:
/usr/sbin:
/bin:
/sbin:
/Applications/splunk/bin:
...& duplicates, snipped...
~/src/blog$ which ghci
ghci is /nix/store/pmha15mrxcnfk19v3wxjh2mhmglvkvw3-ghc-8.8.3-with-packages/bin/ghci
ghci is /usr/local/bin/ghci
ghci is /usr/local/bin/ghci
ghci is /usr/local/bin/ghci

@simonmichael simonmichael changed the title "could not load module errors" at startup "could not load module" errors at startup Jun 25, 2020
@mpscholten
Copy link
Member

This looks as expected. Can you try to run nix-shell --run './start' and then paste the output :) ?

@mpscholten
Copy link
Member

Just to document this for the future:

This problem was just reported again in Gitter. It seems related to the local ghc installation in ~/.ghc/. The workaround currently is to remove ghc-8.8.3 from ~/.ghc/.

@s0kil
Copy link
Collaborator

s0kil commented Jan 15, 2021

I've also just encountered this, fixed my moving ~/.ghc/x86_64-linux-8.10.3/environments/default to ~/.ghc/x86_64-linux-8.10.3/environments/default.backup.

@mpscholten
Copy link
Member

Maybe there's some GHC flag to disable loading files from ~/.ghc. But I'm not aware of that.

In the meantime we could try to add this to the auto troubleshooting script, so atleast people can help themselves in case this issue happens :)

@s0kil
Copy link
Collaborator

s0kil commented Jan 15, 2021

@mpscholten There is: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/packages.html#ghc-flag--package-env%20%E2%9F%A8file%E2%9F%A9|%E2%9F%A8name%E2%9F%A9
I've testing that setting :set -package-env - get's the job done.
Now I'm trying to integrate it into IHP, maybe you could give me some pointers.
Is this the only place it needs to be added? https://github.com/digitallyinduced/ihp/blob/master/exe/IHP/IDE/DevServer.hs#L216-L224

There is also:

I'm not exactly sure the responsibility of each file, do all four of them need to be configured?

@mpscholten
Copy link
Member

Looks good :) Does this then still load the package env provided by nix?

For the dev server the DevServer.hs will do it. We should also add it to applicationGhciConfig, so that people can use ghci.

We could also add it to the Makefile (https://github.com/digitallyinduced/ihp/blob/master/lib/IHP/Makefile.dist#L64) in case someone wants to e.g. build the binaries locally.

@s0kil
Copy link
Collaborator

s0kil commented Jan 15, 2021

Starting ghci and then setting :set -package-env - does not work because ghci already loaded the packages, it would have to be run as ghci -package-env -

Reference: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/ghci.html#setting-ghc-command-line-options-in-ghci

@mpscholten
Copy link
Member

Makes sense. In that case we can likely just ignore the ghci case for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants