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

first stack repl foo:test:bar needs stack build --test --no-run-tests #5213

jneira opened this issue Mar 5, 2020 · 3 comments


Copy link

jneira commented Mar 5, 2020

General summary/comments (optional)

If you starts a repl session in a test component that has dependencies, you need previously build test dependencies with stack build --test --no-run-tests

This causes a bug in hie-bios, that uses stack repl to get the ghc flags needed to start a ghc session in a ide (like haskell-ide-engine or ghcide): haskell/haskell-ide-engine#1564

I guess stack repl project:bench:benchname will have the same behaviour.

Steps to reproduce

In a simple stack project with a test component that has dependencies (hspecfor example) i can reproduce the next cli session:

$ rm -rf $(stack path --snapshot-install-root) # to ensure test dependencies are not already cached

$ rm -rf .stack-work/

$ stack repl project:test:test-name
Warning: Didn't find expected autogen file:
GHCi, version 8.6.5:  :? for help
<command line>: cannot satisfy -package hspec-2.7.1
    (use -v for more information)

$ stack build --test --no-run-tests
Completed 29 action(s)

$ stack repl project:test:test-name
Configuring GHCi with the following packages: stack-test
GHCi, version 8.6.5:  :? for help
[1 of 1] Compiling Main             ( D:\dev\ws\haskell\project\test\MyLibTest.hs, interpreted )
Ok, one module loaded.
Loaded GHCi configuration from D:\\dev\\....

This behaviour is not symmetric with stack build project:test:testname cause it builds test dependencies although you dont provide explicitly --tests and imho is is a bit illogical that user wants to load a test component explicitly in the target but you have to provide --test --no-run-tests to start the repl session.

After a first stack build --test or stack build project:test:testname, with the dependencies in the snapshot, stack repl project:test:testname works until you delete the snapshot dir again.


stack repl project:test:testname should always build test dependencies if needed (and same for bench components)

Stack version

$ stack --version
Version 2.1.3, Git revision 0fa51b9925decd937e4a993ad90cb686f88fa282 (7739 commits) x86_64 hpack-0.31.2

Method of installation

  • Official binary, downloaded from or fpcomplete's package repository
Copy link
Contributor Author

jneira commented May 26, 2020

Hi, while we are using hie-bios in ghcide or haskell-language-server we are hitting a similar issue: stack repl does not build enough to being able to load files inside private libs. Call stack build is required to load them in the repl and in the ide using hie-bios
Original issue: haskell/haskell-language-server#121

@qrilka qrilka self-assigned this May 27, 2020
qrilka added a commit that referenced this issue May 28, 2020
This partially fixes #5213 - starting a repl for an exe component
doesn't appear to work for some reason
Copy link

qrilka commented May 28, 2020

@jneira I have found at least a partial fix for this problem, see #5306

Copy link
Contributor Author

jneira commented May 28, 2020

Many thanks for take care of this!

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

No branches or pull requests

2 participants