Skip to content
This repository has been archived by the owner on May 16, 2024. It is now read-only.

:DevdocsFetch raises "nvim-devdocs: Error when fetching registery, exit code: 2" #31

Closed
Andyson007 opened this issue Aug 26, 2023 · 10 comments

Comments

@Andyson007
Copy link

I know that this issue has already been addressed, but without any solutions.

@Pagliacii
Copy link
Contributor

Pagliacii commented Aug 27, 2023

It seems like the plenary.nvim was using a wrong curl. Executing the curl -sSL https://documents.devdocs.io/rust/index.json?1690404053 manually was fetching file successfully.

P.S. I am using Windows 11, the default curl is C:\WINDOWS\system32\curl.exe

@Andyson007
Copy link
Author

Andyson007 commented Aug 27, 2023

And how do you fix this?

@Andyson007
Copy link
Author

Andyson007 commented Aug 27, 2023

Only difference being that I'm using packer and not lazy.

@luckasRanarison
Copy link
Owner

It's not related to the package manager or the plugin. The issue is either a problem with plenary or curl itself, the error code 2 refers to an internal error from curl.

@Pagliacii
Copy link
Contributor

Pagliacii commented Aug 27, 2023

Oh no, the Windows curl doesn't support the --compressed option. You can execute this code block inside Neovim:

local curl = require("plenary.curl")

vim.print(curl.get("https://devdocs.io/docs.json", {
  dry_run = true,
}))

Copy all code and press the : key, enter this lua <c-r>*<cr> to execute. The result should be like this:

{ "-sSL", "-D", "C:\\Users\\Username\\AppData\\Local\\Temp\\plenary_curl_a93748a1.headers", "--compressed", "-X", "GET", "https://devdocs.io/docs.json" }

And then you can execute this command curl -sSL --compressed -X GET https://devdocs.io/docs.json in the terminal (I'm using PowerShell btw), it will complain:

λ curl -sSL --compressed -X GET https://devdocs.io/docs.json
curl: option --compressed: the installed libcurl version doesn't support this
curl: try 'curl --help' for more information

λ echo $LASTEXITCODE
2

So I think the solution is to change your curl path, don't use the Windows default one.

P.S. You can use this code block to check which curl will be used in plenary:

local Job = require'plenary.job'

Job:new({
  command = 'where',
  args = { 'curl' },
  on_exit = function(j, return_val)
    vim.print(vim.inspect(return_val))
    vim.print(vim.inspect(j:result()))
  end,
}):start()

P.P.S. If you're using the scoop package manager, you can install the curl by this command: scoop install curl. And editing your environment variables, keep the <you scoop path>\shims before the "C:\Windows\System32". After that, everything should be fine.

λ echo $env:SCOOP
<you scoop path>

@Andyson007
Copy link
Author

And how could i replace the curl file used by plenary?

@Pagliacii
Copy link
Contributor

I'm afraid you could not do that easily.

See code below:

  local job_opts = {
    command = "curl",
    args = args,
  }

plenary.nvim doesn't provide an option to specify the curl path, it just finds that in your path environment variables.

@Andyson007
Copy link
Author

yeah Ok it worked to just add the choco bin path in front of sys32 in the path idk why it didn't work previously

@Andyson007
Copy link
Author

Actually I get this error now. Should i create a new issue for this?

Error executing vim.schedule lua callback: ...acker\start\nvim-devdocs/lua/nvim-devdocs/transpiler.lua:340: attempt to perform arithmetic on local 'col_len' (a nil value)
stack traceback:
...acker\start\nvim-devdocs/lua/nvim-devdocs/transpiler.lua:340: in function 'eval_table'
...acker\start\nvim-devdocs/lua/nvim-devdocs/transpiler.lua:225: in function 'eval'
...acker\start\nvim-devdocs/lua/nvim-devdocs/transpiler.lua:388: in function 'fn'
...4\share\nvim\runtime/lua/vim/treesitter/languagetree.lua:341: in function 'for_each_tree'
...acker\start\nvim-devdocs/lua/nvim-devdocs/transpiler.lua:383: in function 'html_to_md'
...ack\packer\start\nvim-devdocs/lua/nvim-devdocs/build.lua:39: in function 'build_docs'
...acker\start\nvim-devdocs/lua/nvim-devdocs/operations.lua:72: in function 'cb'
vim/_editor.lua:263: in function <vim/_editor.lua:262>

@Andyson007 Andyson007 reopened this Aug 27, 2023
@Pagliacii
Copy link
Contributor

See this #32

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants