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

hoogle_signature() [telescope-web handler]: cryptic error message when curl fails #322

Closed
bwkam opened this issue Jan 10, 2024 · 8 comments · Fixed by #323
Closed

hoogle_signature() [telescope-web handler]: cryptic error message when curl fails #322

bwkam opened this issue Jan 10, 2024 · 8 comments · Fixed by #323
Labels
bug Something isn't working

Comments

@bwkam
Copy link

bwkam commented Jan 10, 2024

Neovim version (nvim -v)

0.9.3

Operating system/version

NixOS 24.05

Output of :checkhealth haskell-tools

haskell-tools: require("haskell-tools.health").check()

Checking for Lua dependencies ~
- OK [nvim-telescope/telescope.nvim](https://github.com/nvim-telescope/telescope.nvim) installed.

Checking external dependencies ~
- OK haskell-language-server: found haskell-language-server version: 2.4.0.0 (GHC: 9.4.8) (PATH: /nix/store/cq8xq2anq1wrf6cqnyb3zb0sa23a2p6b-haskell-language-server-2.4.0.0/bin/haskell-language-server-wrapper)
- WARNING       hoogle: not found.
  Install [ndmitchell/hoogle](https://github.com/ndmitchell/hoogle) for extended capabilities.
  Recommended for better Hoogle search performance.
  Without a local installation, the web API will be used by default.
  Required if the hoogle mode is set to "telescope-local".
  
  
- WARNING       fast-tags: not found.
  Install [fast-tags](https://hackage.haskell.org/package/fast-tags) for extended capabilities.
  Optional, for generating tags as a `tagfunc` fallback.
  
- OK curl: found curl 8.4.0 (x86_64-pc-linux-gnu) libcurl/8.4.0 OpenSSL/3.0.12 zlib/1.3 brotli/1.1.0 zstd/1.5.5 libidn2/2.3.4 libssh2/1.11.0 nghttp2/1.57.0
- WARNING       haskell-debug-adapter: not found.
  Install [haskell-debug-adapter](https://github.com/phoityne/haskell-debug-adapter) for extended capabilities.
  Optional, for `dap` support.
  
- WARNING       ghci-dap: not found.
  Install [ghci-dap](https://github.com/phoityne/ghci-dap) for extended capabilities.
  Optional, for `dap` support.
  

Checking config ~
- OK vim.g.haskell_tools is not set
- OK No errors found in config.

Checking for conflicting plugins ~
- OK No conflicting plugins detected.

How to reproduce the issue

:lua require ("haskell-tools").hoogle_signature()

Expected behaviour

Expected telescope to pop up with the hoogle signatures

Actual behaviour

It errors instead.

Log files

E5108: Error executing lua ...tart/haskell-tools.nvim/lua/haskell-tools/hoogle/web.lua:90: Expected value but found invalid token at character 3                                                                        
stack traceback:                                                                                                                                                                                                        
        [C]: in function 'decode'                                                                                                                                                                                       
        ...tart/haskell-tools.nvim/lua/haskell-tools/hoogle/web.lua:90: in function 'on_exit'                                                                                                                           
        ...es/start/haskell-tools.nvim/lua/haskell-tools/compat.lua:38: in function 'system'                                                                                                                            
        ...tart/haskell-tools.nvim/lua/haskell-tools/hoogle/web.lua:82: in function 'handler'                                                                                                                           
        ...es/start/haskell-tools.nvim/lua/haskell-tools/hoogle.lua:110: in function 'hoogle_signature'                                                                                                                 
        [string ":lua"]:1: in main chunk

The minimal config used to reproduce this issue.

Here is my neovim config

@bwkam bwkam added the bug Something isn't working label Jan 10, 2024
@bwkam bwkam changed the title hoogle isn't working properly hoogle_signature() isn't working properly Jan 10, 2024
@bwkam
Copy link
Author

bwkam commented Jan 10, 2024

I assume it fails to fetch a proper response from the hoogle API? Tried running with curl manually and works as expected.

@mrcjkb
Copy link
Owner

mrcjkb commented Jan 10, 2024

Hey 👋

Thanks for reporting.

How to reproduce the issue
:lua require ("haskell-tools").hoogle_signature()

This isn't enough information to reproduce the bug.
Could you please provide more detailed steps?

For example, the following would be useful:

  • A standalone Haskell file, and the commands/keys used to navigate to the location on which to invoke the telescope search.
  • Full file path to the Haskell file.
  • The log files (not the error message) - see the readme's troubleshooting section.

@bwkam
Copy link
Author

bwkam commented Jan 10, 2024

Here is a file producing the same problem.
I just navigated my cursor to triple and then ran :lua require ("haskell-tools").hoogle_signature(), and I get the error I posted above.

logs

[START][2024-01-10 12:18:26] haskell-tools.nvim logging initiated
[START][2024-01-10 12:27:19] haskell-tools.nvim logging initiated
[START][2024-01-10 12:34:32] haskell-tools.nvim logging initiated
[START][2024-01-10 12:40:12] haskell-tools.nvim logging initiated
DEBUG | 2024-01-10 13:00:16 | ...kages/start/haskell-tools.nvim/lua/haskell-tools/lsp.lua:170 | LSP start options: lsp_start_opts
DEBUG | 2024-01-10 13:00:16 | ...kages/start/haskell-tools.nvim/lua/haskell-tools/lsp.lua:138 | LSP attach
DEBUG | 2024-01-10 13:00:55 | ...kages/start/haskell-tools.nvim/lua/haskell-tools/lsp.lua:170 | LSP start options: lsp_start_opts
DEBUG | 2024-01-10 13:00:55 | ...kages/start/haskell-tools.nvim/lua/haskell-tools/lsp.lua:138 | LSP attach
DEBUG | 2024-01-10 13:02:15 | ...es/start/haskell-tools.nvim/lua/haskell-tools/hoogle.lua:97 | { "Hoogle signature search options", {} }
DEBUG | 2024-01-10 13:02:15 | ...es/start/haskell-tools.nvim/lua/haskell-tools/hoogle.lua:22 | { "Hoogle LSP signature search", "[a] -> [a]" }
DEBUG | 2024-01-10 13:02:15 | ...tart/haskell-tools.nvim/lua/haskell-tools/hoogle/web.lua:51 | { "Hoogle web request", "https://hoogle.haskell.org/?hoogle=%5Ba%5D+%2D%3E+%5Ba%5D&mode=json" }
DEBUG | 2024-01-10 13:02:17 | ...tart/haskell-tools.nvim/lua/haskell-tools/hoogle/web.lua:84 | { "Hoogle web response", {    code = 0,    signal = 0,    stdout = "  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current\n                                 Dload  Upload   Total   Spent    Left  Speed\n\r  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0\r  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0\r  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     

-- response --

@mrcjkb mrcjkb changed the title hoogle_signature() isn't working properly hoogle_signature() [telescope-web handler]: cryptic error message when curl fails Jan 10, 2024
@mrcjkb
Copy link
Owner

mrcjkb commented Jan 10, 2024

So I tried reproducing your issue, and couldn't.
My guess (based on the logs) is that your internet connection is slow or unstable and curl is unable to fetch the JSON response from hoogle.

Unfortunately, all I can do here is catch the failure and notify with an appropriate error message.

To work around your problem, you have a few options:

  • Use the browser handler, which opens the URL in a browser (see advanced configuration).
  • Install the hoogle CLI, which will give you better performance than curl.

@bwkam
Copy link
Author

bwkam commented Jan 10, 2024

Yeah, it's quite weird, thanks for looking. My internet is fine, I've tried looking through the source a do some debugging myself, but no luck. I guess I'll go with the local hoogle approach. Should I close?

@mrcjkb
Copy link
Owner

mrcjkb commented Jan 10, 2024

Should I close?

Let's leave this open, I want to add a more informative error notification. 😄

@mrcjkb mrcjkb linked a pull request Jan 10, 2024 that will close this issue
@bwkam
Copy link
Author

bwkam commented Jan 10, 2024

Seems like the nixpkgs version was using an old version (29d7e4a), I've manually overridden it to use 29d7e4a instead, and it's working!

@mrcjkb
Copy link
Owner

mrcjkb commented Jan 10, 2024

Seems like the nixpkgs version was using an old version (29d7e4a), I've manually overridden it to use 29d7e4a instead, and it's working!

Oh yeah, I forgot nixpkgs is always a bit behind 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants