VS Code Extension: Haskell GHCi Debug Adapter Phoityne - Problems

In Visual Studio Code the Haskell Plugin struggle to find the right version of GHC.
Errors are: impossible to find file cradle, it is not possible to recognize ghc version.
I’ve installed all Haskell from the powershell command of this link:
https://www.haskell.org/ghcup/

In Visual Studio Code messages server also crash and it is not restarted.

Stack.yaml is defined in this manner.

stack build is really problematic with many extra-deps tips on errors log added will call other extra-deps tips in the next errors log.


resolver: ghc-9.6.6

packages:

  • .

extra-deps:
– Tips are from stack build log

allow-newer: false

allow-newer-deps:

extra-package-dbs: []

ghc-options: {}

build: {}

install-ghc: true


stack build errors
stack install haskell-debug-adapter difficult to install.

Debug isn’t possible, but normal run of hs file is possible.

Plugin installed haskell v2.4.4
Haskell GHCi Debug Adapter Phoitynev0.

The set of Haskell debug is really problematic. Actually the folder of Haskell is 23 Gigabyte of installed components.
I’ve installed ghcup,stack, cabal, ghc and hls. I cannot find hls.exe
I’ve installed MinGw, with Msys bash and base.
I’ve sh.exe visible as environment path. And all environment keys are good.

Below GhCup List, it is incomplete, but missing elements are all signed as X:
X ghc 9.2.7 base-4.16.4.0
X ghc 9.2.8 base-4.16.4.0 hls-powered
X ghc 9.4.1 base-4.17.0.0
X ghc 9.4.2 base-4.17.0.0
X ghc 9.4.3 base-4.17.0.0
X ghc 9.4.4 base-4.17.0.0
X ghc 9.4.5 base-4.17.1.0
X ghc 9.4.6 base-4.17.2.0
X ghc 9.4.7 base-4.17.2.0
IS ghc 9.4.8 recommended,base-4.17.2.1 hls-powered
X ghc 9.6.1 base-4.18.0.0
X ghc 9.6.2 base-4.18.0.0
X ghc 9.6.3 base-4.18.1.0
X ghc 9.6.4 base-4.18.2.0
X ghc 9.6.5 base-4.18.2.1 hls-powered
X ghc 9.6.6 base-4.18.2.1 hls-powered
X ghc 9.8.1 base-4.19.0.0 2023-10-09
X ghc 9.8.2 base-4.19.1.0 hls-powered,2024-02-23
X ghc 9.10.1 latest,base-4.20.0.0 hls-powered
X cabal 2.4.1.0
X cabal 3.0.0.0
X cabal 3.2.0.0
X cabal 3.4.0.0
X cabal 3.4.1.0
X cabal 3.6.0.0
X cabal 3.6.2.0
X cabal 3.6.2.0-p1
X cabal 3.8.1.0
X cabal 3.10.1.0
X cabal 3.10.2.0
X cabal 3.10.2.1
IS cabal 3.10.3.0 recommended
X cabal 3.12.1.0 latest
X hls 1.1.0
X hls 1.2.0
X hls 1.3.0
X hls 1.4.0
X hls 1.5.0
X hls 1.5.1
X hls 1.6.0.0
X hls 1.6.1.0
X hls 1.7.0.0
X hls 1.8.0.0
X hls 1.9.0.0
X hls 1.9.1.0
X hls 1.10.0.0
X hls 2.0.0.0
X hls 2.0.0.1
X hls 2.1.0.0
X hls 2.2.0.0
X hls 2.3.0.0
X hls 2.4.0.0
X hls 2.5.0.0
X hls 2.6.0.0
X hls 2.7.0.0
X hls 2.8.0.0
X hls 2.9.0.0
IS hls 2.9.0.1 latest,recommended
X stack 2.5.1
X stack 2.7.1
X stack 2.7.3 2022-02-02
X stack 2.7.5
X stack 2.9.1
X stack 2.9.3
X stack 2.11.1
X stack 2.13.1
X stack 2.15.1
X stack 2.15.3
X stack 2.15.5
X stack 2.15.7
IS stack 3.1.1 latest,recommended
IS ghcup 0.1.30.0 latest,recommended

Problems with stack install phoityne-vscode:
phoityne-vscode> [103 of 107] Compiling Phoityne.VSCode.TH.SetBreakpointsResponseBodyJSON
phoityne-vscode> [104 of 107] Compiling Phoityne.VSCode.TH.SetBreakpointsResponseJSON
phoityne-vscode> [105 of 107] Compiling Phoityne.VSCode.Core
phoityne-vscode>
phoityne-vscode> app\Phoityne\VSCode\Core.hs:2762:41: error: [GHC-76037]
phoityne-vscode> Not in scope: FSN.confDebounce' phoityne-vscode> NB: the module System.FSNotify’ does not export confDebounce'. phoityne-vscode> | phoityne-vscode> 2762 | FSN.withManagerConf FSN.defaultConfig{FSN.confDebounce = FSN.Debounce 1} $ \mgr -> do phoityne-vscode> | ^^^^^^^^^^^^^^^^ phoityne-vscode> phoityne-vscode> app\Phoityne\VSCode\Core.hs:2762:61: error: [GHC-76037] phoityne-vscode> Not in scope: data constructor FSN.Debounce’
phoityne-vscode> NB: the module System.FSNotify' does not export Debounce’.
phoityne-vscode> |
phoityne-vscode> 2762 | FSN.withManagerConf FSN.defaultConfig{FSN.confDebounce = FSN.Debounce 1} $ \mgr → do
phoityne-vscode> | ^^^^^^^^^^^^

Error: [S-7282]
Stack failed to execute the build plan.

   While executing the build plan, Stack encountered the error:

   [S-7011]
   While building package phoityne-vscode-0.0.28.0 (scroll up to its section to see the error) using:
   C:\Users\Dell\AppData\Roaming\stack\setup-exe-cache\x86_64-windows\Cabal-simple_CKvAmRb3_3.10.3.0_ghc-9.6.5.exe --verbose=1 --builddir=.stack-work\dist\eebe39f7 build --ghc-options " -fdiagnostics-color=always"
   Process exited with code: ExitFailure 1

Despite it is one day that i try to solve all problems, it is impossible to fix all them.
At the end the situation is like the begin.

With new project created with stack new and the yaml file with snapshot on:
url: “URL /lts/22/36.yaml”

The command:
stack ghci --with-ghc=ghci-dap --test --no-load --no-build --main-is TARGET
gives this error;

Warning: The following GHC options are incompatible with GHCi and have not been passed
to it: -threaded.

Configuring GHCi with the following packages: haskell-project-n3-stack.
[DAP][INFO] start ghci-dap-0.0.23.0.
GHCi, version 9.6.5: :? for help

:1:1: error: [GHC-52243]
Bad interface file: C:\Users\Dell\AppData\Local\Programs\stack\x86_64-windows\ghc-9.6.6\lib\x86_64-windows-ghc-9.6.6\ghc-prim-0.10.0\GHC\Types.hi
mismatched interface file versions (wanted “9065”, got “9066”)

If ghc 9.6.6 is installed visible with environment path and set with “ghc set 9.6.6”.Visual Studio Code try to load ghc 9.6.6.
So there isn’t a good comunication between Visual Studio plugins and file installed from GHCup

Some few issues are present on stackoverflow about that,

It is needed the possibility to have a good installation for Windows and an easy pre-configuration for yaml project files and better automation for installation and update options.

Thank you.

2 Likes

With Stack on Windows 11, I command:

stack unpack phoityne-vscode # fetch a local copy of the package from Hackage
cd phoityne-vcsode-0.0.28.0
stack init # picks snapshot lts-22.36 (GHC 9.6.6)
stack build

The package does not build, but that is not due to Stack. Errors:

app\Phoityne\VSCode\Core.hs:2762:41: error: [GHC-76037]
    Not in scope: ‘FSN.confDebounce’
    NB: the module ‘System.FSNotify’ does not export ‘confDebounce’.
     |
2762 |   FSN.withManagerConf FSN.defaultConfig{FSN.confDebounce  = FSN.Debounce 1} $ \mgr -> do
     |                                         ^^^^^^^^^^^^^^^^

app\Phoityne\VSCode\Core.hs:2762:61: error: [GHC-76037]
    Not in scope: data constructor ‘FSN.Debounce’
    NB: the module ‘System.FSNotify’ does not export ‘Debounce’.
     |
2762 |   FSN.withManagerConf FSN.defaultConfig{FSN.confDebounce  = FSN.Debounce 1} $ \mgr -> do
     |                                                             ^^^^^^^^^^^^

I think there is a missing upper bound in the package description for the package (that is, in its Cabal file): fsnotify < 0.4.

So, I set Stack’s project-level configuration file (stack.yaml) to specify an earlier version of fsnotify, as follows:

snapshot: lts-22.36
extra-deps:
- fsnotify-0.3.0.1

Again, it does not build. However, that is because module Phoityne.VSCode.Core uses liftIO but fails to import it. So I add to the module:

import Control.Monad.IO.Class ( liftIO )

Now stack build works as expected.

Also, the ‘Haskell’ extension for VS Code works as expected - it does not need a cradle to detect Stack and the correct version of GHC.

1 Like

In your Stack project-level configuration file (stack.yaml), you are specifying a ‘compiler-only’ snapshot (resolver: ghc-9.6.6). That snapshot specifies only a version of GHC and its boot packages. So, you are having to bring in a lot of other package versions as extra-deps.

If you use a Stackage snapshot (for example, snapshot: lts-22.36) it will specify a version of GHC (in that case, GHC 9.6.6) and a large number of package versions that are known, by testing, to work well together.

1 Like

Stack build functions properly using commands yor recomnnended and adding. But the problem is also the configuration for the launh yaml file to set the right debugger.

The last errors reported had the snapshot of stack yaml init instead of ghc-9.6.6:
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/22/36

I’ve created a new project with stack init and used after Visual Studio Code to add the yaml files.
This is the launch.yaml file as tip from ChatGBT:
{

"version": "0.2.0",

"configurations": [

  {

    "type": "ghc",

    "request": "launch",

    "name": "Haskell Debug",

    "internalConsoleOptions": "openOnSessionStart",

    "workspace": "${workspaceFolder}",

    "startup": "${workspaceFolder}/app/Main.hs",

    "startupFunc": "",

    "startupArgs": "",

    "stopOnEntry": false,

    "mainArgs": "",

    "ghciPrompt": "H>>= ",

    "ghciInitialPrompt": "> ",

    "ghciCmd": "stack ghci --with-ghc=ghci-dap --test --no-load --no-build --main-is TARGET",

    "ghciEnv": {},

    "logFile": "${workspaceFolder}/.vscode/phoityne.log",

    "logLevel": "WARNING",

    "forceInspect": false

  }

]

}

At the end i newly done the recommended command from Haskell Phoityne Debugger:
stack install haskell-dap ghci-dap haskell-debug-adapter and it functions for the project.

Now, i don’t know why the debug is started, but there too problem to solve rapidly the problem. I.ve noted that using the tools for console and Unix all is immediate and fast, with the possibility to load configurations desired. But for Visual Studio Code there is the lack for configuration of yaml files package and stack, the difficulty to have a pre configuration for the launch jason file of Visual Studio Code and the difficulty to have a proper installation from ghcup for the particular project. Other than that the automated functions for installation and setup of Visual Studio disappears or don’t comunicate well with GhCup. Some of these issues are reported from GitHub, stackoverflow and other sites.

stack init requires that any word is divided from hyphens is only numbers, there is to know if this is to follow ths particular request in any project.

I’ve started a new project from new without using stack init. Using a new project i have a folder name “progetto 4” and defined dependencies as progetto4 without spaces in package yaml. I’ve added to this project the stack yaml and project yaml of the project created with stack new and used the launch jason as it have been built from ChatGBT. The debug of project runs properly.

I noticed that Phitoyne does not permit input commands:

Variables watch: the variable are visible once used in some expression, not in all the scope in which they are visible

Some tool to set up all these files is needed and easily available to get a full access to this language with visual IDE’s.

Thank you for help.

I can help with Stack, especially on Windows, and I use VS Code, but I don’t know the application that you are, ultimately, trying to use.

The ‘URL version’ of the Stackage LTS 22.36 snapshot is just another way to specify the same snapshot.

stack new <project_name> creates a single-package project from a template. For that reason, the given project directory name needs to be also a valid package name (which means one or more alphanumeric ‘words’ separated by hyphens, where the ‘words’ cannot be confused with numbers). However, stack init (which tries to create a Stack project-level configuration file from one or more existing package description files) does not require the project directory name to be a valid package name.

1 Like

I now see that the author of phoityne-vscode-0.0.28.0 has abandoned the package in favour of package haskell-debug-adapter, without marking the former as deprecated on Hackage. I can build the latter with Stack on Windows 11, and copy its executable to a defined location (which is on my PATH), by:

> stack unpack haskell-debug-adapter
> cd haskell-debug-adapter-0.0.40.0
> stack install # Copy the built executable to a defined location
> haskell-debug-adapter.exe --version
haskell-debug-adapter-0.0.40.0

with stack.yaml:

snapshot: lts-22.36 # GHC 9.6.6
extra-deps:
- haskell-dap-0.0.16.0
- ghci-dap-0.0.23.0

The author’s diagram:

diagram

indicates that the ghci-dap executable is also required. I can build it, and copy it to a defined location, with:

> stack unpack ghci-dap
> cd ghci-dap-0.0.23.0
> stack install
> ghci-dap --version
[DAP][INFO] start ghci-dap-0.0.23.0.
The Glorious Glasgow Haskell Compilation System, version 9.6.6

with stack.yaml:

snapshot: lts-22.36 # GHC 9.6.6
extra-deps:
- haskell-dap-0.0.16.0
2 Likes