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

Haskell GHCi Debug Adapter can't start #42

Open
hjoly2003 opened this issue Mar 24, 2019 · 8 comments
Open

Haskell GHCi Debug Adapter can't start #42

hjoly2003 opened this issue Mar 24, 2019 · 8 comments

Comments

@hjoly2003
Copy link

I can't start the Haskell debugger.
After having installed the debug adapter and created a dummy project, I've set a break point and started the debugger (F5). A debugger floating toolbox briefly appeared, vanished, then..., nothing. And no debugger log file (phoityne.log) got created under the .vscode sub-directory.

CONTEXT:

  • macOs Sierra 10.12.6
  • ghc 8.6.4
  • stack 1.9.3
  • vscode 1.32.3
  • Haskell Syntax Highlighting 2.5.0
  • haskell-linter 0.0.6
  • Haskell GHCi Debug Adapter Phoityne 0.0.22

DETAILS:

I have created a project with the following command
iMac:~ usr$ stack new my-project
iMac:~ usr$ cd my-project
iMac:my-project usr$ stack setup
iMac:my-project usr$ stack build

I have installed the dependencies of the Debug Adapter with the following command.
iMac:my-project usr$ stack build --copy-compiler-tool phoityne-vscode haskell-dap

The binaries got installed under ~/.stack/compiler-tools/x86_64-osx/ghc-8.6.4/bin.
I have included that directory in the PATH environment variable. I always launch vscode through the UNIX terminal under the my-projectdirectory so that the IDE has access to this PATH environment variable.

Here are the versions of the dependencies I have installed:
iMac:my-project usr$ phoityne-vscode --version
phoityne-vscode-0.0.28.0
iMac:my-project usr$ haskell-dap --version
haskell-dap-0.0.12.0
iMac:my-project usr$ hlint --version
HLint v2.1.11, (C) Neil Mitchell 2006-2018

Here is the content of the launch.json used for the Debug Adapter:
launch_json

Please note that I'm using --with-ghc=haskell-dap for the ghciCmd variable. But if I try this command in a terminal window within my project directory...
iMac:my-project usr$ stack ghci --test --no-load --no-build --with-ghc=haskell-dap --main-is TARGET --ghci-options -fprint-evld-with-show
I get the following:
The following GHC options are incompatible with GHCi and have not been passed to it: -threaded
Configuring GHCi with the following packages: my-project
[DAP][INFO] start haskell-dap-0.0.12.0.
GHCi, version 8.6.4: http://www.haskell.org/ghc/ :? for help
haskell-dap:
lookupSymbol failed in relocateSection (relocate external)
/Users/utilisationnormale/.stack/programs/x86_64-osx/ghc-8.6.4/lib/ghc-8.6.4/unix-2.7.2.2/HSunix-2.7.2.2.o: unknown symbol '_utimensat'
haskell-dap: unable to load package 'unix-2.7.2.2'

But if, in the terminal window, I try the same command without the --with-ghc=haskell-dap then it works. I tried to remove that from the launch.json but the debugger does't start in vscode.

As a final note, I've also tried the debugger after having replaced ${workspaceFolder} with the path of the project within the launch.json file. Alas, I got the same result.

Thanks in advance,

@phoityne
Copy link
Owner

Hi.
I don't have mac os, so might be wrong,
but asking some questions.

Q1
Have you installed xcode ?

$ xcode-select --install

I am not sure, but seems that there are some cases of problem about "_utimensat" symbol,
without xcode-select on mac os.

Q2
Does below command work in your project dir ?

$ which haskell-dap
$ stack exec haskell-dap -- --interactive

Q3
Does haskell-dap work if you install it by "stack install" ?

$ stack install phoityne-vscode haskell-dap
$ which haskell-dap
$ stack ghci --with-ghc=haskell-dap

There seems to be a problem with finding/loading shared libraries,
might be able to link it by setting DYLD_LIBRARY_PATH.

Regards.

@hjoly2003
Copy link
Author

Hi, let me first say that my PATH was wrongly defined.

Within my .bash_profile, I was using ~ for defining my home directory. So, instead of having
export PATH=~/.local/bin:$PATH
I now have
export PATH=$HOME/.local/bin:$PATH.

This solves the problem partially. I can now run the debugger without the --with-ghc=haskell-dap clause. It can stop to breakpoints but, with that configuration, I have a feeling that some functionalities aren't supported. For example, when I'm in a function, I cannot use the debugger to "Step Out" to the calling function.

If I put back the --with-ghc=haskell-dap within my launch.json, when I start the debugger, I now get the following popup:
popup

Although I could work with a debugger without haskell-dap, I'd like to be able to have a debugger with a full feature-set (i.e. with --with-ghc=haskell-dap). So, in order to resolve the issue, here are my answers to your questions.

Q1 - Have you installed xcode ?

Yes, I have Xcode 9.2

Q2 - Does below command work in your project dir ?

`$ which haskell-dap`

Yes, it gives...
/Users/username/.stack/compiler-tools/x86_64-osx/ghc-8.6.4/bin/haskell-dap
And ...
stack exec haskell-dap -- --interactive
works...

As for the third question, here's what I get if, in the terminal widow, I run the following command within my project subdirectory...
iMap: my-project user$ stack ghci --with-ghc=haskell-dap
I get the following...
Using main module: 1. Package 'my-project' component exe:my-project-exe with main-is file: /Users/utilisationnormale/my-project/app/Main.hs
The following GHC options are incompatible with GHCi and have not been passed to it: -threaded
Configuring GHCi with the following packages: my-project
[DAP][INFO] start haskell-dap-0.0.12.0.
GHCi, version 8.6.4: http://www.haskell.org/ghc/ :? for help
[1 of 3] Compiling Lib ( /Users/utilisationnormale/my-project/src/Lib.hs, interpreted )
[2 of 3] Compiling Main ( /Users/utilisationnormale/my-project/app/Main.hs, interpreted )
[3 of 3] Compiling Phoityne.Example.Math ( /Users/utilisationnormale/my-project/src/Phoityne/Example/Math.hs, interpreted )
Ok, three modules loaded.
Loaded GHCi configuration from /private/var/folders/cf/sjn91k_j2qv3rmpy22ndh3sc0000gq/T/haskell-stack-ghci/045cf6c8/ghci-script
*Main Lib Phoityne.Example.Math>

So, besides the -threaded option, it looks like the thing works. But if I run the full command found in the launch.json (within the ghiCmdvariable), I get the output shown in my first email.

Finally, if I type the following:
$ which ghci
I get the following,
/usr/local/bin/ghci
And...
$ ls -lart /usr/local/bin/ghci
gives...
lrwxr-xr-x 1 root admin 68 23 fév 20:57 /usr/local/bin/ghci -> /Library/Frameworks/GHC.framework/Versions/8.6.3-x86_64/usr/bin/ghci

Hope that you can help.

@phoityne
Copy link
Owner

Firstly, "Step Out" is not supported with haskell-dap.
ghci does not have step out command.

Could you change log level to DEBUG in the launch.json file and run again ?
Is there anything shown in the debug console?

Might works with "stack clean" & "stack test" from terminal, in the project dir.

Regards.

@hjoly2003
Copy link
Author

Hi, trying "stack clean" & "stack test" didn't make any difference for the debugger.

Here's part of the output of the phoityne.log after having set the log level to DEBUG:

`2019-03-29 19:48:18 [ThreadId 5] INFO phoityne - [EVENT]{"seq":3,"type":"event","event":"output","body":{"category":"stdout","output":"CMD: stack ghci --test --no-load --no-build --with-ghc=haskell-dap --main-is TARGET --ghci-options -fprint-evld-with-show \n\n","data":null}}

2019-03-29 19:48:20 [ThreadId 5] INFO phoityne - [EVENT]{"seq":4,"type":"event","event":"output","body":{"category":"stdout","output":"The following GHC options are incompatible with GHCi and have not been passed to it: -threaded\nConfiguring GHCi with the following packages: my-project\n[DAP][INFO] start haskell-dap-0.0.12.0.\nGHCi, version 8.6.4: http://www.haskell.org/ghc/ :? for help\nhaskell-dap: \nlookupSymbol failed in relocateSection (relocate external)\n/Users/utilisationnormale/.stack/programs/x86_64-osx/ghc-8.6.4/lib/ghc-8.6.4/unix-2.7.2.2/HSunix-2.7.2.2.o: unknown symbol _utimensat'\nhaskell-dap: unable to load package unix-2.7.2.2'\n","data":null}}

2019-03-29 19:48:20 [ThreadId 5] INFO phoityne - [EVENT]{"seq":5,"type":"event","event":"output","body":{"category":"stdout","output":":set prompt "H>>= "\n","data":null}}

2019-03-29 19:48:20 [ThreadId 5] INFO phoityne - [RESPONSE]{"seq":6,"type":"response","request_seq":2,"success":false,"command":"launch","message":"ghci launch error. <file descriptor: 32>: hPutChar: resource vanished (Broken pipe)"}

2019-03-29 19:48:20 [ThreadId 5] ERROR phoityne - ghci launch error. <file descriptor: 32>: hPutChar: resource vanished (Broken pipe)`

I thinks that the problem is related to the fact that the Haskell unix-2.7.2.2 module isn't installed:
There is no directory named unix-2.7.2.2under /Users/utilisationnormale/.stack/programs/x86_64-osx/ghc-8.6.4/lib/ghc-8.6.4. It looks like the mac version of haskell-dap depends on it.

Can you confirm this so that my next step would be to install that package via Cabal?

Thanks,

@hjoly2003 hjoly2003 reopened this Apr 1, 2019
@hjoly2003
Copy link
Author

Hi, checking the haskell-dap package.yaml has shown a dependency to unix package.

I tried to install that package by the following:
$ stack intall unix
but nothing happened.

First, I'd expect that my installation of haskell-dap should have installed the unix package since it depends on it. Am I right assuming that stack can do that?

Lastly, how should I install the unix package? Although it is listed on stackage, there no documentation about how to install it. And the documentation on hackage is, to say the least, very minimal.

Thanks,

btw, I've closed this issue in my last reply accidentally.

@phoityne
Copy link
Owner

phoityne commented Apr 4, 2019

First, I'd expect that my installation of haskell-dap should have installed the unix package since it
depends on it. Am I right assuming that stack can do that?

Yes, stack will install it.
I have been trying to reproduce on centos7, but haven't yet.
On centos7, there is a directory after running "stack setup".
~/.stack/programs/x86_64-linux/ghc-8.6.4/lib/ghc-8.6.4/unix-2.7.2.2

(means without installing haskell-dap, just stack setup.)

How about trying to reinstall ghc?
Just rename ~/.stack, and run "stack setup".
~/.stack directory will be recreated.

Regards.

@mouse07410
Copy link

@hjoly2003 just in case, check your stack configuration: ~/.stack/config.yaml and ~/.stack/global-project/stack.yaml. The first file may prevent stack from installing its own copy of ghc if system-ghc: true is set, and the second one may define resolver: xxxxxx which may or may not work for you.

@bsdshell
Copy link

bsdshell commented Nov 8, 2020

I try to run haskell-language-server in one of my stack project,
I got following error:

Message: Installation error: unable to load package `unix-2.7.2.2'

ghc-8.8.4
macOS Sierra

lookupSymbol failed in relocateSection (relocate external)
/Users/cat/.stack/programs/x86_64-osx/ghc-8.8.4/lib/ghc-8.8.4/unix-2.7.2.2/HSunix-2.7.2.2.o: unknown symbol _utimensat' Hidden: no Range: 1:1-2:1 Source: typecheck Severity: DsError Message: Installation error: unable to load package unix-2.7.2.2'

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

4 participants