phoityne / haskell-dap

Haskell implementation of DAP interface data.
https://hackage.haskell.org/package/haskell-dap
BSD 3-Clause "New" or "Revised" License
24 stars 3 forks source link

ghci launch error #7

Closed ghost closed 5 years ago

ghost commented 5 years ago

Trying to debug Haskell project on Ubuntu using vscode with installed extensions:

$ lsb_release -a
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.5 LTS
Release:    16.04
Codename:   xenial
$ stack ghc -- --version
The Glorious Glasgow Haskell Compilation System, version 8.4.4
$ stack --version
Version 1.9.3, Git revision 40cf7b37526b86d1676da82167ea8758a854953b (6211 commits) x86_64 hpack-0.31.1
$ code --version
1.30.1
dea8705087adb1b5e5ae1d9123278e178656186a
x64

When I create a simple project from template by: $ stack new my-project simple

Also --with-ghc=haskell-dap switch added to ghciCmd, when try to debug project I get this error: err

phoityne commented 5 years ago

Could you check that phoityne and haskell-dap are on the path?

$ phoityne-vscode --version
phoityne-vscode-0.0.27.0

$
$ haskell-dap --version
[DAP][INFO] start haskell-dap-0.0.10.0.
The Glorious Glasgow Haskell Compilation System, version 8.6.2

$
ghost commented 5 years ago
$ phoityne-vscode --version
phoityne-vscode-0.0.27.0

$ haskell-dap --version
haskell-dap: error while loading shared libraries: libHShaskell-dap-0.0.10.0-407MUV9jwTaDFLezcL3vgg-ghc8.4.4.so: cannot open shared object file: No such file or directory

It seems something is wrong with haskell-dap. So I tried to install it again:

$ stack install haskell-dap
haskell-dap-0.0.10.0: configure
haskell-dap-0.0.10.0: build
haskell-dap-0.0.10.0: copy/register
Copying from ~/.stack/global-project/.stack-work/install/x86_64-linux/lts-13.1/8.6.3/bin/haskell-dap to ~/.local/bin/haskell-dap

Copied executables to ~/.local/bin:
- haskell-dap

Still same error pops up:

$ haskell-dap --version
haskell-dap: error while loading shared libraries: libHShaskell-dap-0.0.10.0-L2FcaAXP5m3JvgCyqL5gzc-ghc8.6.3.so: cannot open shared object file: No such file or directory
phoityne commented 5 years ago

I have rebproduced this issue on CentOS7.

[phoityne@centos7 ~]$ which haskell-dap
~/.local/bin/haskell-dap
[phoityne@centos7 ~]$
[phoityne@centos7 ~]$ haskell-dap --version
haskell-dap: error while loading shared libraries: libHShaskell-dap-0.0.10.0-L2FcaAXP5m3JvgCyqL5gzc-ghc8.6.3.so: cannot open shared object file: No such file or directory
[phoityne@centos7 ~]$

If there is .so file, setting LD_LIBRARY_PATH will work.

[phoityne@centos7 ~]$
[phoityne@centos7 ~]$ find .stack | grep dap | grep so
.stack/global-project/.stack-work/install/x86_64-linux/lts-13.1/8.6.3/lib/x86_64-linux-ghc-8.6.3/libHShaskell-dap-0.0.10.0-L2FcaAXP5m3JvgCyqL5gzc-ghc8.6.3.so
[phoityne@centos7 ~]$
[phoityne@centos7 ~]$ export LD_LIBRARY_PATH=/home/phoityne/.stack/global-project/.stack-work/install/x86_64-linux/lts-13.1/8.6.3/lib/x86_64-linux-ghc-8.6.3
[phoityne@centos7 ~]$
[phoityne@centos7 ~]$ haskell-dap --version
[DAP][INFO] start haskell-dap-0.0.10.0.
The Glorious Glasgow Haskell Compilation System, version 8.6.3
[phoityne@centos7 ~]$
[phoityne@centos7 ~]$

I will look into build options of haskell-dap to be able to using it without setting LD_LIBRARY_PATH.

phoityne commented 5 years ago

I have changed build options of haskell-dap library. Could you try it again with version 0.0.10.1 ? (confirmed it works on CentOS7 with no env setting)

Regards.

ghost commented 5 years ago

Updated to haskell-dap 0.0.10.1 and can check the version without error:

$ haskell-dap --version
[DAP][INFO] start haskell-dap-0.0.10.1.
The Glorious Glasgow Haskell Compilation System, version 8.6.3

But when trying to debug same error pops up (line number is changed):

hdap

Debug console info:

CMD: stack ghci --test --no-load --no-build --main-is TARGET --ghci-options --with-ghc=haskell-dap -fprint-evld-with-show 
Invalid option `-fprint-evld-with-show'
Usage: stack ghci [TARGET/FILE] [--ghci-options OPTIONS] [--ghc-options OPTIONS]
                  [--flag PACKAGE:[-]FLAG] [--with-ghc GHC] [--[no-]load]
                  [--package ARG] [--main-is TARGET] [--load-local-deps]
                  [--[no-]package-hiding] [--only-main] [--trace] [--profile]
                  [--no-strip] [--[no-]test] [--[no-]bench] [--help]
  Run ghci in the context of package(s) (experimental)
------------------------------------
can not parse ghci version. ["getGHCiVersion" (line 9, column 1):
unexpected end of input
expecting "GHCi, version "] assumes 8.0.0.
------------------------------------
:set prompt "H>>= "
ghost commented 5 years ago

I removed -fprint-evld-with-show option from launch.json but then I get following error in debug console:

CMD: stack ghci --test --no-load --no-build --main-is TARGET --ghci-options --with-ghc=haskell-dap 
Configuring GHCi with the following packages: myproject
GHCi, version 8.6.3: http://www.haskell.org/ghc/  :? for help
ghc: unrecognised flag: --with-ghc=haskell-dap
Usage: For basic information, try the `--help' option.
:set prompt "H>>= "
ghci launch error. <file descriptor: 59>: hPutChar: resource vanished (Broken pipe)
phoityne commented 5 years ago

"--with-ghc" is the option of stack command. so, add this option just after "stack ghci", not after "--ghci-options" option.

"ghciCmd": "stack ghci --with-ghc=haskell-dap --test . . . ",

Regards.

ghost commented 5 years ago

Everything works fine by now.

image

Thanks :rose:

ghost commented 5 years ago

Just another thing. When I run simple template app it works and prints hello world on console but in debug mode nothing is printed on debug console. Is it OK?

phoityne commented 5 years ago

Could be, yes. depends on log level.

In the launch.json file, by setting logLevel to "INFO", all ghci console log will be shown in the vscode terminal.

"logLevel": "INFO"

Regards.

steve3p0 commented 5 years ago

Hello, I am trying to do the same thing. I want to debug Haskell with Visual Studio Code.

I am using the following extensions:

But the "--with-ghc=haskell-dap" option causes the IDE to just hang. I made sure that phoityne-vscode and haskell-dap are configured properly.

Check configuration:

PS C:\gf-rgl> phoityne-vscode --version
phoityne-vscode-0.0.28.0

PS C:\gf-rgl> haskell-dap --version
[DAP][INFO] start haskell-dap-0.0.12.0.
The Glorious Glasgow Haskell Compilation System, version 8.6.4

So if I launch debugging in Visual Studio Code with ghciCmd set to the following in launch.json:

stack ghci --with-ghc=haskell-dap --test --no-load --no-build --main-is tests --ghci-options -fprint-evld-with-show

It spits out the output below and then just hangs. If I take the "--with-ghc=haskell-dap" option out, it runs without error. Can someone tell me briefly what these options do and why do we want these specific launch options to use in the Visual Studio Code IDE?

Thanks, Steve

Output of "stack ghci --with-ghc=haskell-dap" ghciCmd in launch.json:

CWD: C:\workspace_courses\gf_steve3po\gf-rgl\tests 
CMD: stack ghci --with-ghc=haskell-dap --test --no-load --no-build --main-is tests --ghci-options -fprint-evld-with-show 
The following GHC options are incompatible with GHCi and have not been passed to it: -threaded
Configuring GHCi with the following packages: tests
[DAP][INFO] start haskell-dap-0.0.12.0.
GHCi, version 8.6.4: http://www.haskell.org/ghc/  :? for help
Prelude>:set prompt "H>>= "
 H>>= :set prompt-cont "H>>= "
H>>= :load C:/workspace_courses/gf_steve3po/gf-rgl/tests/run.hs
[1 of 1] Compiling Main             ( C:\workspace_courses\gf_steve3po\gf-rgl\tests\run.hs, interpreted )
Ok, one module loaded.
H>>= :module + *Main
H>>= :set -fno-break-on-exception
H>>= :set -fno-break-on-error
H>>= 
  Now, ghci launched and configuration done.
  Press F5 to start debugging.
  Or modify source code. it will be loaded to ghci automatically.

H>>=