first `stack repl foo:test:bar` needs `stack build --test --no-run-tests`
jneira opened this issue · comments
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 (hspec
for 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:
D:\dev\ws\haskell\project\.stack-work\dist\e626a42b\build\project\autogen\cabal_macros.h
GHCi, version 8.6.5: http://www.haskell.org/ghc/ :? 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: http://www.haskell.org/ghc/ :? 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\\....
*Main>
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.
Expected
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 stackage.org or fpcomplete's package repository
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
Many thanks for take care of this!