luckasRanarison / nvim-devdocs

Neovim DevDocs integration
MIT License
265 stars 19 forks source link

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

Closed Andyson007 closed 1 year ago

Andyson007 commented 1 year ago

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

Pagliacii commented 1 year ago

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 commented 1 year ago

And how do you fix this?

Andyson007 commented 1 year ago

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

luckasRanarison commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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

Pagliacii commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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>

Pagliacii commented 1 year ago

See this #32