General summary/comments (optional)
The current working dir at compile time is different between stack build and stack repl. It likely makes template haskell io computations relying in cwd fail, cause the relative file or directory usually does not exist.
This in turn makes that code not usable in a ide (hls, ghcide) that uses hie-bios to manage ghc session, as hie-bios uses stack repl underneath for stack projects.
(original issue haskell/haskell-language-server#481)
Steps to reproduce
- Create a simple stack project with a main package with an exe and a subpackage with a lib
- Create in the subpackage lib a module with
import System.Directory
import Language.Haskell.TH
import Language.Haskell.TH.Syntax
cwd :: FilePath
cwd = $$(runIO getCurrentDirectory >>= \d-> fmap TExp (lift (d :: FilePath)))
and in the main package an executable with
- Run command
stack run and observe cwd is /path/to/main/package/subpackage
- Run command
stack repl subpackage or stack repl and observe cwd evaluation gives us /path/to/main/package
Expected
Both paths should be equal.
Actual
stack build uses the subpackage path and stack repl the main package one
Stack version
$ stack --version
Version 2.5.1 x86_64 hpack-0.33.0
Method of installation
- Official binary, downloaded from stackage.org or fpcomplete's package repository
General summary/comments (optional)
The current working dir at compile time is different between
stack buildandstack repl. It likely makes template haskell io computations relying in cwd fail, cause the relative file or directory usually does not exist.This in turn makes that code not usable in a ide (hls, ghcide) that uses
hie-biosto manage ghc session, ashie-biosusesstack replunderneath for stack projects.(original issue haskell/haskell-language-server#481)
Steps to reproduce
and in the main package an executable with
stack runand observe cwd is/path/to/main/package/subpackagestack repl subpackageorstack repland observe cwd evaluation gives us/path/to/main/packageExpected
Both paths should be equal.
Actual
stack builduses the subpackage path andstack replthe main package oneStack version
Method of installation