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

Launch ghci in file directory instead of VSCode directory #96

Open
4 tasks
ZZYSonny opened this issue Oct 19, 2021 · 0 comments
Open
4 tasks

Launch ghci in file directory instead of VSCode directory #96

ZZYSonny opened this issue Oct 19, 2021 · 0 comments

Comments

@ZZYSonny
Copy link

Status

  • A workaround is available
  • A fix is written
  • A fix is released
  • The fixed version is on the marketplace.

  • Version of vscode-ghc-simple: 0.2.3
  • Version of VSCode: 1.16.1, under Remote-WSL
  • Version of Haskell-related tools:
    • GHC: 8.10.7
    • Stack: 2.7.3
    • Cabal:

Steps to reproduce

In an empty folder, create two files A.hs, B.hs.

module A where
    f = 1
import A

main = print f

See B.hs. Simple GHCI cannot load module A from A.hs.
image
Whereas ghci will load both file.
image

Analysis

From the log, I can see ghci is launched in the vscode installation directory, instead of the file directory. So that is why simple GHCI cannot find A.hs.

The temporary fix for this is to add custom startup commands.

    "ghcSimple.startupCommands.custom": [
        ":cd /home/zzysonny/Code/Year3/PPL/PPLPrac1/src"
    ]

But this is rather complicated when I have multiple folders in the vscode folder. So I hope there can be an extra settings. GHCI working directory, which can be workspaceFolder, fileFolder, custom string. It may be even nicer if VSCode variables are supported. https://code.visualstudio.com/docs/editor/variables-reference

GHC log

Starting for /home/zzysonny/Code/Year3/PPL/PPLPrac1/src/B.hs, key = null
Starting GHCi with: "stack exec ghci"
(Under default cwd)
    -> :set prompt ""
    |> :set prompt-cont ""
ghci | GHCi, version 8.10.7: https://www.haskell.org/ghc/  :? for help
ghci | Prelude> 
ghci | ===ghci_barrier_0.7034031005801691===
    -> System.IO.hSetBuffering System.IO.stderr System.IO.NoBuffering
    |> System.IO.hSetBuffering System.IO.stdout System.IO.NoBuffering
    |> :set -fno-diagnostics-show-caret -fdiagnostics-color=never -ferror-spans
    |> :set -fdefer-type-errors -fdefer-typed-holes -fdefer-out-of-scope-variables
    |> :seti -fno-defer-type-errors -fno-defer-typed-holes -fno-defer-out-of-scope-variables
    |> :set -haddock
    |> :set -fno-hide-source-paths
    |> :set -Wno-error=missing-home-modules
    |> :set -Wall
    |> :seti -Wno-type-defaults
ghci | 
ghci | ===ghci_barrier_0.1119618591666034===
    -> :show paths
ghci | current working directory: 
ghci |   /mnt/c/Users/ZZYSonny/AppData/Local/Programs/Microsoft VS Code
ghci | module import search paths:
ghci |   .
ghci | 
ghci | ===ghci_barrier_0.2321228477367394===
Detected base path: /mnt/c/Users/ZZYSonny/AppData/Local/Programs/Microsoft VS Code
    -> :set +c
    |> :load "*/home/zzysonny/Code/Year3/PPL/PPLPrac1/src/B.hs"
ghci | [1 of 1] Compiling Main             ( /home/zzysonny/Code/Year3/PPL/PPLPrac1/src/B.hs, interpreted )
ghci | 
ghci | /home/zzysonny/Code/Year3/PPL/PPLPrac1/src/B.hs:1:1-8: error:
ghci |     Could not find module ‘A’
ghci |     Use -v (or `:set -v` in ghci) to see a list of the files searched for.
ghci | Failed, no modules loaded.
ghci | 
ghci | ===ghci_barrier_0.195905576407559===
    -> :show modules
ghci | 
ghci | ===ghci_barrier_0.6250371529182739===
    -> :module
ghci | 
ghci | ===ghci_barrier_0.052739456129852647===
    -> :info import
ghci | 
ghci | <interactive>:1:1-6: error: parse error on input ‘import’
ghci | 
ghci | ===ghci_barrier_0.1925448730709982===
    -> :m *undefined
ghci | syntax:  :module [+/-] [*]M1 ... [*]Mn
ghci | 
ghci | ===ghci_barrier_0.5590384475373995===
    -> :doc import
ghci | 
ghci | <interactive>:1:1-6: error: parse error on input ‘import’
ghci | 
ghci | ===ghci_barrier_0.7454267742644956===
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

1 participant