haskelly-dev / Haskelly

Haskelly is a VS Code extension that provides complete support for casual and expert Haskell development.
https://marketplace.visualstudio.com/items?itemName=UCL.haskelly
GNU General Public License v3.0
152 stars 17 forks source link

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

Open bobcrane opened 2 years ago

bobcrane commented 2 years ago

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 commented 6 months ago

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