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

Failed to load interface for 'Prelude' when invoking GHCi with test target #1222

Closed
mrkkrp opened this issue Oct 24, 2015 · 5 comments
Closed
Assignees

Comments

@mrkkrp
Copy link
Collaborator

mrkkrp commented Oct 24, 2015

I'm trying to switch to Stack completely and so I need to use it to run REPL. As I understand stack ghci is the correct command for this. I have a project with a library, two test suites and a benchmark. This command works OK:

$ stack ghci myproject:lib --no-load

Then I can use :m to load file of interest (otherwise all modules are loaded at once, given that some of them are intended to be imported qualified, it's not what I usually want). However, when I need to work with tests, I get this:

$ stack ghci myproject:test:mytestsuite --no-load
Using main module: Package `mypackage' component test:mytestsuite with main-is file: /some/path/here
Configuring GHCi with the following packages: myproject
GHCi, version 7.10.2: http://www.haskell.org/ghc/  :? for help

<interactive>:1:1:
    Failed to load interface for ‘Prelude’
    It is a member of the hidden package ‘base-4.8.1.0’.
    Use -v to see a list of the files searched for.

How is that? The test suite specifies base >= 4.6 && < 5 in Cabal file, so it cannot be hidden. I would normally think that this is sort of problem with my configuration, but stack test and other commands work fine.

@mrkkrp
Copy link
Collaborator Author

mrkkrp commented Oct 27, 2015

Living without REPL sometimes can be quite painful. Is there something I can do to use REPL with non-default build target?

@mgsloan
Copy link
Contributor

mgsloan commented Oct 28, 2015

@mrkkrp I figured that your repro case is stack ghci megaparsec:tests. That should indeed work. I fixed 3 things and now it does :D

Can you please close this issue if the latest stack version fixes the issue?

@mgsloan mgsloan self-assigned this Oct 28, 2015
@mrkkrp
Copy link
Collaborator Author

mrkkrp commented Oct 28, 2015

@mgsloan, It works now! Thank you very much.

@mac10688
Copy link

mac10688 commented Nov 3, 2015

I have the same issue. How did you upgrade your version of stack? I did "stack upgrade" but it said I'm at the latest. I have a workaround for now. I just ":l test/test.hs", but it would be nice to just load my test suite directly.

@mgsloan
Copy link
Contributor

mgsloan commented Nov 3, 2015

@mac10688 stack upgrade --git to get the latest development version.

dysinger added a commit that referenced this issue Nov 13, 2015
* master: (106 commits)
  Fix ghci -package-id for lib dep from test #1222
  Fix passing of include dirs to GHCI #1222
  Minor change to some local var naming
  Fix a copy-o which breaks ghci test targets #1222
  Only ask for commit count once when compiling
  Move Windows installers above manual download
  Import all modules after loading them (#995)
  replace if then else with case matching (multiway if)
  Control/Concurrent/Execute.hs : redundant do
  Use stack setup so you can ignore most of the output
  Don't cache the GHC folder
  Strip -static before passing to GHCi (#1094)
  Fix: unlisted files in tests and benchmarks trigger extraneous second build (fixes #838)
  Don't fail when registering/looking up library for executable-only packages #1232
  Fix help for default true bool flag's enable hint
  Rebuild when cabal file is changed
  watched command: show files, not directories
  Update changelog
  Fix: Haddocks not copied for dependencies (fixes #1105)
  Remove redundant Version from InstalledMap
  ...
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

No branches or pull requests

4 participants