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

Working directory not set correctly in GHCi due to --ghci-options parameter #105

Open
bobcrane opened this issue Mar 22, 2022 · 1 comment

Comments

@bobcrane
Copy link

bobcrane commented Mar 22, 2022

I'm using Visual Studio Code in Windows 10 with a project created with the stack new command.

When I click the Load GHCi button with a source code file selected in VCS the following commands are executed in the powershell terminal:

cd "j:\bobhaskell\bobtest\src" (runs fine)
PS J:\bobhaskell\bobtest\src> stack ghci --ghci-options Lib.hs

The problem is that Lib.hs fails to load:
<no location info>: error: can't find file: Lib.hs

The problem seems to be that GHCI shows the working directory to be one level up and not in the src directory itself.
ghci> :show paths
current working directory:
J:\bobhaskell\bobtest

Manually running stack ghci Lib.hs without the --ghci-options works fine though it compiles less stuff including Main.hs.

Why is the current working directory not being set correctly when using --ghci-options?

Below is the full ouput:

PS J:\bobhaskell\bobtest> cd "j:\bobhaskell\bobtest\src"
PS J:\bobhaskell\bobtest\src> stack ghci --ghci-options Lib.hs
Using main module: 1. Package `bobtest' component bobtest:exe:bobtest-exe with main-is file: J:\bobhaskell\bobtest\app\Main.hs
bobtest> initial-build-steps (lib + exe)
The following GHC options are incompatible with GHCi and have not been passed to it: -threaded
Configuring GHCi with the following packages: bobtest
GHCi, version 9.0.2: https://www.haskell.org/ghc/ :? for help
[1 of 3] Compiling Lib ( J:\bobhaskell\bobtest\src\Lib.hs, interpreted )
[2 of 3] Compiling Main ( J:\bobhaskell\bobtest\app\Main.hs, interpreted )
[3 of 3] Compiling Paths_bobtest ( J:\bobhaskell\bobtest.stack-work\dist\d53b6a14\build\autogen\Paths_bobtest.hs, interpreted )
Ok, three modules loaded.
Loaded GHCi configuration from C:\Users\Bob\AppData\Local\Temp\haskell-stack-ghci\78312b92\ghci-script

: error: can't find file: Lib.hs
Failed, no modules loaded.

ghci> :show paths
current working directory:
J:\bobhaskell\bobtest
module import search paths:
J:\bobhaskell\bobtest.stack-work\dist\d53b6a14\build
J:\bobhaskell\bobtest\src
J:\bobhaskell\bobtest.stack-work\dist\d53b6a14\build\autogen
J:\bobhaskell\bobtest.stack-work\dist\d53b6a14\build\global-autogen
ghci>

@ForeverRainmaN
Copy link

Experiencing the same exact issue, is there any workaround besides doing it manually like you did?

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

2 participants