Skip to content

stack repl subpackage compile time cwd is different from stack build subpackage one #5421

Closed
@jneira

Description

@jneira

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

  1. Create a simple stack project with a main package with an exe and a subpackage with a lib
  2. 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

main = print cwd
  1. Run command stack run and observe cwd is /path/to/main/package/subpackage
  2. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions