Skip to content

Help debugging HLS! #237

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

Closed
awgn opened this issue Jul 26, 2020 · 6 comments
Closed

Help debugging HLS! #237

awgn opened this issue Jul 26, 2020 · 6 comments
Labels
type: support User support tickets, questions, help with setup etc.

Comments

@awgn
Copy link

awgn commented Jul 26, 2020

Hi there,

I'm experiencing weird problems while running hls on a library I'm working on. From vscode I'm not able to see any special problem. I've checked the output, everything seems to be right, but then nothing happens. Mouse over doesn't work, even though from the log I can't see errors:

2020-07-26 09:54:40.164255 [ThreadId 276] - Hover request at position 42:9 in file: /Users/admin/GitLab/vegoia-tree-lib/src/Vegoia/DecisionTree/Model.hs
2020-07-26 09:54:40.365894 [ThreadId 279] - GhcIde.hover entered (ideLogger)

What's the correct way to run HLS with --debug option? Didn't find any help from the documentation. Do I need to run a special wrapper, or is there a way from vscode to run hls in debug+verbose mode?

I forgot to mention that the haskell-ide-engine tool does work instead.

Thanks,
N.

@lukel97
Copy link
Collaborator

lukel97 commented Jul 26, 2020

Hi, can you paste the full log from the output window? It could be that the session didn't get set up correctly which doesn't always produce obvious errors. You can also get some more debugging information if you can find the path to the haskell-language-server binary, which should be in the output window somewhere, and running that in the terminal in the root directory of your project with no arguments

@awgn
Copy link
Author

awgn commented Jul 27, 2020

Hi bubba,

here's the log:

[client] debug command: "haskell-language-server-wrapper --lsp -d"
[client] server cwd: undefined
Module "/Users/admin/GitLab/vegoia-tree-lib/a" is loaded by Cradle: Cradle {cradleRootDir = "/Users/admin/GitLab/vegoia-tree-lib", cradleOptsProg = CradleAction: Stack}
Run entered for haskell-language-server-wrapper(haskell-language-server-wrapper) Version 0.2.2.0, Git revision cbdf0a4e5936cb17ac7f2d2df672c2fa1e23284d (393 commits) x86_64 ghc-8.8.4
Current directory: /Users/admin/GitLab/vegoia-tree-lib
Operating system: darwin
Arguments: ["--lsp"]
Cradle directory: /Users/admin/GitLab/vegoia-tree-lib
Cradle type: Stack
Consulting the cradle to get project GHC version...
Project GHC version: 8.8.2
haskell-language-server exe candidates: ["haskell-language-server-8.8.2","haskell-language-server-8.8","haskell-language-server"]
Launching haskell-language-server exe at:/Users/admin/.local/bin/haskell-language-server-8.8
haskell-language-server version: 0.2.2.0 (GHC: 8.8.4) (PATH: /Users/admin/.local/bin/haskell-language-server-8.8) (GIT hash: cbdf0a4e5936cb17ac7f2d2df672c2fa1e23284d)
Starting (haskell-language-server)LSP server...
  with arguments: Arguments {argLSP = True, argsCwd = Nothing, argFiles = [], argsVersion = False, argsShakeProfiling = Nothing, argsTesting = False, argsExamplePlugin = False, argsDebugOn = False, argsLogFile = Nothing, argsThreads = 0, argsProjectGhcVersion = False}
  with plugins: [PluginId "brittany",PluginId "eval",PluginId "floskell",PluginId "ghcide",PluginId "ormolu",PluginId "pragmas",PluginId "stylish-haskell"]
  in directory: /Users/admin/GitLab/vegoia-tree-lib
If you are seeing this in a terminal, you probably should have run ghcide WITHOUT the --lsp option!
 Started LSP server in 0.02s
2020-07-27 08:58:24.418448 [ThreadId 21] - Opened text document: file:///Users/admin/GitLab/vegoia-tree-lib/src/Vegoia/DecisionTree/FlowSample.hs
Data.HashMap.Base.(!): key not found
CallStack (from HasCallStack):
  error, called at ./Data/HashMap/Base.hs:631:16 in unordered-containers-0.2.10.0-L0UCiFV6BpAyFeQZxTEW6:Data.HashMap.Base
2020-07-27 08:58:24.422115 [ThreadId 61] - Consulting the cradle for "/Users/admin/GitLab/vegoia-tree-lib/src/Vegoia/DecisionTree/FlowSample.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/Users/admin/GitLab/vegoia-tree-lib", cradleOptsProg = CradleAction: Stack}
> The following GHC options are incompatible with GHCi and have not been passed to it: -O2
> Configuring GHCi with the following packages: vegoia-tree-lib
> /Users/admin/GitLab/vegoia-tree-lib/.stack-work/install/x86_64-osx/48f6e8c3aa2666127717add4dde2ccf130aec2c609be78e4f501d7766e16a5f7/8.8.2/pkgdb:/Users/admin/.stack/snapshots/x86_64-osx/48f6e8c3aa2666127717add4dde2ccf130aec2c609be78e4f501d7766e16a5f7/8.8.2/pkgdb:/Users/admin/.stack/programs/x86_64-osx/ghc-8.8.2/lib/ghc-8.8.2/package.conf.d
2020-07-27 08:58:27.230905 [ThreadId 83] - finish: CodeAction (took 0.00s)
2020-07-27 08:58:27.231004 [ThreadId 83] - finish: CodeAction:PackageExports (took 0.00s)
2020-07-27 08:58:27.231096 [ThreadId 91] - Plugin.makeCodeLens (ideLogger)
2020-07-27 08:58:27.231621 [ThreadId 83] - finish: codeLens (took 0.00s)
2020-07-27 08:58:27.498947 [ThreadId 83] - finish: CodeAction (took 0.00s)
2020-07-27 08:58:27.499045 [ThreadId 83] - finish: CodeAction:PackageExports (took 0.00s)
2020-07-27 08:58:49.379481 [ThreadId 97] - GhcIde.hover entered (ideLogger)
2020-07-27 08:58:49.379653 [ThreadId 97] - Hover request at position 318:18 in file: /Users/admin/GitLab/vegoia-tree-lib/src/Vegoia/DecisionTree/FlowSample.hs
2020-07-27 08:58:50.34809 [ThreadId 100] - GhcIde.hover entered (ideLogger)
2020-07-27 08:58:50.348293 [ThreadId 100] - Hover request at position 319:19 in file: /Users/admin/GitLab/vegoia-tree-lib/src/Vegoia/DecisionTree/FlowSample.hs
2020-07-27 08:58:51.224645 [ThreadId 103] - GhcIde.hover entered (ideLogger)
2020-07-27 08:58:51.224864 [ThreadId 103] - Hover request at position 321:25 in file: /Users/admin/GitLab/vegoia-tree-lib/src/Vegoia/DecisionTree/FlowSample.hs
2020-07-27 08:58:53.31695 [ThreadId 106] - GhcIde.hover entered (ideLogger)
2020-07-27 08:58:53.317102 [ThreadId 106] - Hover request at position 331:16 in file: /Users/admin/GitLab/vegoia-tree-lib/src/Vegoia/DecisionTree/FlowSample.hs

Interestingly, by running manually hls wrapper without arguments I get:

haskell-language-server-wrapper
Module "/Users/admin/GitLab/vegoia-tree-lib/a" is loaded by Cradle: Cradle {cradleRootDir = "/Users/admin/GitLab/vegoia-tree-lib", cradleOptsProg = CradleAction: Stack}
Run entered for haskell-language-server-wrapper(haskell-language-server-wrapper) Version 0.2.2.0, Git revision cbdf0a4e5936cb17ac7f2d2df672c2fa1e23284d (393 commits) x86_64 ghc-8.8.4
Current directory: /Users/admin/GitLab/vegoia-tree-lib
Operating system: darwin
Arguments: []
Cradle directory: /Users/admin/GitLab/vegoia-tree-lib
Cradle type: Stack
Consulting the cradle to get project GHC version...
Project GHC version: 8.8.2
haskell-language-server exe candidates: ["haskell-language-server-8.8.2","haskell-language-server-8.8","haskell-language-server"]
Launching haskell-language-server exe at:/Users/admin/.local/bin/haskell-language-server-8.8
haskell-language-server version: 0.2.2.0 (GHC: 8.8.4) (PATH: /Users/admin/.local/bin/haskell-language-server-8.8) (GIT hash: cbdf0a4e5936cb17ac7f2d2df672c2fa1e23284d)
(haskell-language-server)Ghcide setup tester in /Users/admin/GitLab/vegoia-tree-lib.
Report bugs at https://github.com/haskell/haskell-language-server/issues

Step 1/4: Finding files to test in /Users/admin/GitLab/vegoia-tree-lib
Found 6 files

Step 2/4: Looking for hie.yaml files that control setup
Found 1 cradle

Step 3/4: Initializing the IDE

Step 4/4: Type checking the files
[INFO] Consulting the cradle for "/Users/admin/GitLab/vegoia-tree-lib/src/Vegoia/DecisionTree/UserAgentSample.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/Users/admin/GitLab/vegoia-tree-lib", cradleOptsProg = CradleAction: Stack}
> The following GHC options are incompatible with GHCi and have not been passed to it: -O2
> Configuring GHCi with the following packages: vegoia-tree-lib
> /Users/admin/GitLab/vegoia-tree-lib/.stack-work/install/x86_64-osx/48f6e8c3aa2666127717add4dde2ccf130aec2c609be78e4f501d7766e16a5f7/8.8.2/pkgdb:/Users/admin/.stack/snapshots/x86_64-osx/48f6e8c3aa2666127717add4dde2ccf130aec2c609be78e4f501d7766e16a5f7/8.8.2/pkgdb:/Users/admin/.stack/programs/x86_64-osx/ghc-8.8.2/lib/ghc-8.8.2/package.conf.d
File:     /Users/admin/GitLab/vegoia-tree-lib/src/Vegoia/DecisionTree/UserAgentSample.hs
Hidden:   no
Range:    1:0-2:0
Source:   cradle
Severity: DsError
Message:
  ghcide compiled against GHC 8.8.4 but currently using 8.8.2
  This is unsupported, ghcide must be compiled with the same GHC version as the project.
[INFO] Consulting the cradle for "/Users/admin/GitLab/vegoia-tree-lib/Setup.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/Users/admin/GitLab/vegoia-tree-lib", cradleOptsProg = CradleAction: Stack}
> The following GHC options are incompatible with GHCi and have not been passed to it: -O2
> Configuring GHCi with the following packages: vegoia-tree-lib
> /Users/admin/GitLab/vegoia-tree-lib/.stack-work/install/x86_64-osx/48f6e8c3aa2666127717add4dde2ccf130aec2c609be78e4f501d7766e16a5f7/8.8.2/pkgdb:/Users/admin/.stack/snapshots/x86_64-osx/48f6e8c3aa2666127717add4dde2ccf130aec2c609be78e4f501d7766e16a5f7/8.8.2/pkgdb:/Users/admin/.stack/programs/x86_64-osx/ghc-8.8.2/lib/ghc-8.8.2/package.conf.d
File:     /Users/admin/GitLab/vegoia-tree-lib/Setup.hs
Hidden:   no
Range:    1:0-2:0
Source:   cradle
Severity: DsError
Message:
  ghcide compiled against GHC 8.8.4 but currently using 8.8.2
  This is unsupported, ghcide must be compiled with the same GHC version as the project.
[INFO] Consulting the cradle for "/Users/admin/GitLab/vegoia-tree-lib/src/Vegoia/DecisionTree/Feature.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/Users/admin/GitLab/vegoia-tree-lib", cradleOptsProg = CradleAction: Stack}
> The following GHC options are incompatible with GHCi and have not been passed to it: -O2
> Configuring GHCi with the following packages: vegoia-tree-lib
> /Users/admin/GitLab/vegoia-tree-lib/.stack-work/install/x86_64-osx/48f6e8c3aa2666127717add4dde2ccf130aec2c609be78e4f501d7766e16a5f7/8.8.2/pkgdb:/Users/admin/.stack/snapshots/x86_64-osx/48f6e8c3aa2666127717add4dde2ccf130aec2c609be78e4f501d7766e16a5f7/8.8.2/pkgdb:/Users/admin/.stack/programs/x86_64-osx/ghc-8.8.2/lib/ghc-8.8.2/package.conf.d
File:     /Users/admin/GitLab/vegoia-tree-lib/src/Vegoia/DecisionTree/Feature.hs
Hidden:   no
Range:    1:0-2:0
Source:   cradle
Severity: DsError
Message:
  ghcide compiled against GHC 8.8.4 but currently using 8.8.2
  This is unsupported, ghcide must be compiled with the same GHC version as the project.
[INFO] Consulting the cradle for "/Users/admin/GitLab/vegoia-tree-lib/src/Vegoia/DecisionTree.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/Users/admin/GitLab/vegoia-tree-lib", cradleOptsProg = CradleAction: Stack}
> The following GHC options are incompatible with GHCi and have not been passed to it: -O2
> Configuring GHCi with the following packages: vegoia-tree-lib
> /Users/admin/GitLab/vegoia-tree-lib/.stack-work/install/x86_64-osx/48f6e8c3aa2666127717add4dde2ccf130aec2c609be78e4f501d7766e16a5f7/8.8.2/pkgdb:/Users/admin/.stack/snapshots/x86_64-osx/48f6e8c3aa2666127717add4dde2ccf130aec2c609be78e4f501d7766e16a5f7/8.8.2/pkgdb:/Users/admin/.stack/programs/x86_64-osx/ghc-8.8.2/lib/ghc-8.8.2/package.conf.d
File:     /Users/admin/GitLab/vegoia-tree-lib/src/Vegoia/DecisionTree.hs
Hidden:   no
Range:    1:0-2:0
Source:   cradle
Severity: DsError
Message:
  ghcide compiled against GHC 8.8.4 but currently using 8.8.2
  This is unsupported, ghcide must be compiled with the same GHC version as the project.
[INFO] Consulting the cradle for "/Users/admin/GitLab/vegoia-tree-lib/src/Vegoia/DecisionTree/Model.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/Users/admin/GitLab/vegoia-tree-lib", cradleOptsProg = CradleAction: Stack}
> The following GHC options are incompatible with GHCi and have not been passed to it: -O2
> Configuring GHCi with the following packages: vegoia-tree-lib
> /Users/admin/GitLab/vegoia-tree-lib/.stack-work/install/x86_64-osx/48f6e8c3aa2666127717add4dde2ccf130aec2c609be78e4f501d7766e16a5f7/8.8.2/pkgdb:/Users/admin/.stack/snapshots/x86_64-osx/48f6e8c3aa2666127717add4dde2ccf130aec2c609be78e4f501d7766e16a5f7/8.8.2/pkgdb:/Users/admin/.stack/programs/x86_64-osx/ghc-8.8.2/lib/ghc-8.8.2/package.conf.d
File:     /Users/admin/GitLab/vegoia-tree-lib/src/Vegoia/DecisionTree/Model.hs
...

Looks like the error is:

**
ghcide compiled against GHC 8.8.4 but currently using 8.8.2
This is unsupported, ghcide must be compiled with the same GHC version as the project.
**

How can this be possible? I have just compiled the tool with stack ./install.hs hls. Do I need to manually build for each compiler?

@Ailrun
Copy link
Member

Ailrun commented Jul 27, 2020

Yes, if you are using GHC 8.8.2, you should build hls-8.8.2 to use HLS with the compiler.
Ref: https://github.com/haskell/haskell-language-server#install-specific-ghc-version

@Ailrun Ailrun added the type: support User support tickets, questions, help with setup etc. label Jul 27, 2020
@awgn
Copy link
Author

awgn commented Jul 27, 2020

My fault! Issue resolved. Thanks

@awgn awgn closed this as completed Jul 27, 2020
@lukel97
Copy link
Collaborator

lukel97 commented Jul 27, 2020

With that said, should we maybe get rid of the haskell-language-server-8.8 symlinks since they're not guaranteed to work? I.e. only symlink haskell-language-server and haskell-language-server-8.x.y, not haskell-language-server-8.x

@awgn
Copy link
Author

awgn commented Jul 27, 2020

I think another thing that could be really helpful would be having such an error reported in vscode (output).

pepeiborra pushed a commit that referenced this issue Dec 27, 2020
* Add tests for issue #237

* Tell hlint to ignore test sample code

* Add test showing similar problem in listcomps

* Identify implementation necessary for test to pass
pepeiborra pushed a commit that referenced this issue Dec 27, 2020
* Cleaner Show instance for SpanInfo

This helped with debugging #237, so maybe it's worth keeping.

* Stylistic fixes
pepeiborra pushed a commit that referenced this issue Dec 27, 2020
The bug was caused by broken transitivity of the comparison function used to
sort spans. Nested spans were meant to be sorted in innermost-first order, with
the first (innermost) one being used to get type information about the symbol at
a given position.

Because the comparison function considered any two non-nested spans to be EQ,
the sort could incorrectly conclude (by transitivity) that two nested spans were
equal, and thus leave them in incorrect relative order. This resulted in the
innermost span sometimes not appearing at the front of the list of spans which
enclose a given point, and hover reporting the type of a bigger expression in
which the point appeared.

The solution imposes ordering on non-nested spans by comparing their starting
positions, thus fixing transitivity.

Fixes #237 (... probably along with a bunch of other little bugs caused by the
same mistake).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: support User support tickets, questions, help with setup etc.
Projects
None yet
Development

No branches or pull requests

3 participants