rest.nvim icon indicating copy to clipboard operation
rest.nvim copied to clipboard

Installation Troubleshooting Guide

Open boltlessengineer opened this issue 1 year ago • 10 comments

Related: #463 #477 #493 #497

I wrote an installation troubleshooting guide to help people having issues while installing this plugin.

Feel free to open a new issue if you still have any issue after following this guide!

boltlessengineer avatar Dec 12 '24 14:12 boltlessengineer

Even though checkhealth tells me everything is ok, I still have trouble running requests, when three or four months ago it was working fine. By the way, hererocks is set to true in my configuration.

:checkhealth lazy

lazy: require("lazy.health").check()

lazy.nvim ~

  • {lazy.nvim} version 11.16.2
  • OK {git} version 2.39.5 (Apple Git-154)
  • OK no existing packages found by other package managers
  • OK packer_compiled.lua not found

luarocks ~

  • checking hererocks installation
  • you have some plugins that require luarocks:
    • hererocks
    • rest.nvim
  • OK {python3} Python 3.13.1
  • OK {/Users/uchoa/.local/share/nvim/lazy-rocks/hererocks/bin/luarocks} 3.11.1
  • OK {/Users/uchoa/.local/share/nvim/lazy-rocks/hererocks/bin/lua} Lua 5.1.5 Copyright (C) 1994-2012 Lua.org, PUC-Rio

I'm not sure if I should reopen https://github.com/rest-nvim/rest.nvim/issues/537, or create a new issue, or do something else.

uchoa avatar Mar 12 '25 18:03 uchoa

@uchoa do you get exactly same error message from #537? What's the output of :checkhealth rest-nvim?

boltlessengineer avatar Mar 13 '25 01:03 boltlessengineer

Yes. That's the error message I get. :checkhealth rest-vim outputs:

rest-nvim: require("rest-nvim.health").check()

Installation ~
- WARNING `Luarocks` is not installed in your system
  - ADVICE:
    - Are you sure you installed all needed dependencies properly?
- OK Found Luarocks PATHs in your Neovim's Lua `package.path`
- OK Dependency `xml2lua` was found
- OK Dependency `mimetypes` was found
- OK Dependency `fidget.nvim` was found
- OK Dependency `nvim-nio` was found

Response body formatters ~
- WARNING Options 'formatexpr' or 'formatprg' are not set for json filetype
- OK Option 'formatexpr' is set to `xmlformat#Format()` for xml filetype
- WARNING Options 'formatexpr' or 'formatprg' are not set for html filetype
- You can set formatter for each filetype via 'formatexpr' or 'formatprg' option

Even though I get ok when : checkhealth lazy.

uchoa avatar Mar 13 '25 17:03 uchoa

As I answered your questions, I remembered that I had installed neovim using homebrew, so I decided to install luarocks also using homebrew, just in case.

Now checkhealth rest-nvim outputs:

==============================================================================
rest-nvim: require("rest-nvim.health").check()

Installation ~
- OK Found `luarocks` installed in your system
- OK Found Luarocks PATHs in your Neovim's Lua `package.path`
- OK Dependency `mimetypes` was found
- OK Dependency `nvim-nio` was found
- OK Dependency `fidget.nvim` was found
- OK Dependency `xml2lua` was found

Response body formatters ~
- WARNING Options 'formatexpr' or 'formatprg' are not set for json filetype
- OK Option 'formatexpr' is set to `xmlformat#Format()` for xml filetype
- WARNING Options 'formatexpr' or 'formatprg' are not set for html filetype
- You can set formatter for each filetype via 'formatexpr' or 'formatprg' option

The error message is still the same, though.

uchoa avatar Mar 13 '25 17:03 uchoa

@uchoa The system luarocks & lua version should not matter because lazy will automatically install them. Actually I'd recommend to not install both lua or luarocks from homebrew because they are missing the required versions unless you set rocks.hererocks = true from our lazy.nvim config.

I wonder why lazy.nvim didn't throw an error during installation... 🤔

Can you reproduce it with this minimal config? Save the snippet below as repro.lua and run nvim -u repro.lua. It will create .repro/ directory in cwd and clean install rest.nvim with minimal lazy.nvim config. You can remove the .repro directory after testing.

vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()

require("lazy.minit").repro({
    rocks = {
        hererocks = true,
    },
    spec = {
        "rest-nvim/rest.nvim",
        {
            "nvim-treesitter/nvim-treesitter",
            build = ":TSUpdate",
            main = "nvim-treesitter.configs",
            opts = {
                ensure_installed = { "http" },
                sync_install = false,
                highlight = { enable = true },
                indent = { enable = true },
            },
        },
    },
})

If this works, try setting rocks.hererocks = true on your lazy.nvim config (reference: https://lazy.folke.io/configuration), uninstall rest.nvim and reinstall it.

Edit: fixed typo in repro.lua snippet.

boltlessengineer avatar Mar 14 '25 03:03 boltlessengineer

rocks.hererocks is already true in my lazy config. But I'll try your suggestion and bring the feedback here.

uchoa avatar Mar 17 '25 15:03 uchoa

Similar error. I had to manually install luarocks to make this work. And I have lazy ^11.17.

CudaSlayer avatar Mar 21 '25 14:03 CudaSlayer

@CudaSlayer Do you still have to install luarocks while setting rocks.hererocks = true? Because that's exactly why hererocks option exists, to use correct luarocks version instead of system one that might have mismatched version.

boltlessengineer avatar Mar 21 '25 14:03 boltlessengineer

@CudaSlayer Do you still have to install luarocks while setting rocks.hererocks = true? Because that's exactly why hererocks option exists, to use correct luarocks version instead of system one that might have mismatched version.

@boltlessengineer Didn't test it. I just used the snippet that was in the readme:

{
  "rest-nvim/rest.nvim",
  dependencies = {
    "nvim-treesitter/nvim-treesitter",
    opts = function (_, opts)
      opts.ensure_installed = opts.ensure_installed or {}
      table.insert(opts.ensure_installed, "http")
    end,
  }
}

Then I ran into a plethora of errors after installing rest. Then I had to manually install http, new errors cropped up. After I checked for :checkhealth rest.nvim, I saw luarocks wasn't installed, so I installed it. I came to check the GH issues if someone had similar issues and found one.

CudaSlayer avatar Mar 21 '25 17:03 CudaSlayer

@CudaSlayer uninstall rest.nvim and try reinstall it with rocks.hererocks = true option set as I suggested in troubleshooting guide. Feel free to ask again if you still have trouble after following the guide.

boltlessengineer avatar Mar 21 '25 17:03 boltlessengineer

@uchoa The system luarocks & lua version should not matter because lazy will automatically install them. Actually I'd recommend to not install both lua or luarocks from homebrew because they are missing the required versions unless you set rocks.hererocks = true from our lazy.nvim config.

I wonder why lazy.nvim didn't throw an error during installation... 🤔

@boltlessengineer, I'm sorry if I forgot to come back here earlier. I tried uninstalling and reinstalling rest.nvim and the issue remained.

I ended up cleaning up my whole Neovim configuration as well as the cached plugins. Then reconfigured it with the same plugins, copying back the same config files, plugin by plugin until everything was back in place and rest.nvim was back, up and running. Besides that I did nothing else. I have no idea why it didn't work before and now it does. No clue about which other plugin might be causing problems, or even if that was actually the case. It seems I had to get out of the car and get back in again before being able to turn it on.

uchoa avatar Jul 05 '25 04:07 uchoa

Next works with:

  • Neo/Vim plugin manage https://github.com/junegunn/vim-plug
  • Ubuntu 24.04
  • init.vim instead of init.lua as NeoVim config file
if has('nvim')
  " Dependencies
  "
  " tree-sitter
  " https://tree-sitter.github.io/tree-sitter/using-parsers/1-getting-started.html
  " https://github.com/nvim-treesitter/nvim-treesitter/issues/1097#issuecomment-2512543496
  " Run: npm install -g tree-sitter-cli
  "
  " nvim-treesitter
  " https://github.com/nvim-treesitter/nvim-treesitter
  Plug 'nvim-treesitter/nvim-treesitter', { 'branch': 'main' }
  " Test with: `:checkhealth nvim-treesitter`
  "
  " tree-sitter-http
  " https://github.com/rest-nvim/tree-sitter-http
  " https://github.com/nvim-treesitter/nvim-treesitter#adding-parsers
  " Run: `:TSInstallFromGrammar http`
  "
  " HTTP filetypes
  autocmd BufEnter *.http :setlocal filetype=http
  "
  " LuaRocks
  " https://github.com/luarocks/luarocks/blob/main/docs/installation_instructions_for_unix.md
  " Run: sudo apt install build-essential libreadline-dev unzip
  " Run: sudo apt install luarocks # v3.8.0
  "
  " Add LuaRocks to package path
  au VimEnter *.http luafile <path>/LuaRocks/settings.lua
  "
  " mimetypes
  " https://luarocks.org/modules/lunarmodules/mimetypes
  " Run: sudo luarocks install mimetypes # mimetypes 1.1.0-2 is now installed in /usr/local
  "
  " xml2lua
  " https://luarocks.org/modules/manoelcampos/xml2lua
  " Run: sudo luarocks install xml2lua # xml2lua 1.6-2 is now installed in /usr/local
  "
  " fidget.nvim
  " https://github.com/j-hui/fidget.nvim
  Plug 'j-hui/fidget.nvim'
  "
  " nvim-nio
  " https://github.com/nvim-neotest/nvim-nio
  Plug 'nvim-neotest/nvim-nio'

  " Load BEFORE rest.nvim is loaded
  luafile <path>/rest.nvim/settings.lua

  " https://github.com/rest-nvim/rest.nvim
  Plug 'rest-nvim/rest.nvim'
endif

<path>/LuaRocks/settings.lua content (¿optional??):

-- LuaRocks install path to package.path and package.cpath (add this before any plugin configuration)
local luarocks_path = os.getenv("HOME") .. "/.luarocks/lib/lua/5.1/?.so;"
package.cpath = package.cpath .. ";" .. luarocks_path
local luarocks_lua_path = os.getenv("HOME") .. "/.luarocks/share/lua/5.1/?.lua;"
package.path = package.path .. ";" .. luarocks_lua_path

<path>/rest.nvim/settings.lua content (optional):

vim.g.rest_nvim = {
    ui = {
        keybinds = {
            prev = "p",
            next = "n",
        },
    },
}

Test:

  1. HTTP script
echo "GET https://jsonplaceholder.typicode.com/posts/1" > test.http
nvim test.http

2 (optional) Run :checkhealth rest-nvim 3. Observe the syntax parsing done by tree-sitter-http 4. Run :Rest run 5. Change to new window and press n or p to cycle

I hope this help to no lazy.nvim nor rocks.nvim users.

It would be awesome if your an installation troubleshooting guide, @boltlessengineer , could include steps for this other plugin manager too. Please.

I coded it by try-and-error, so I guarantee nothing.

PD. sudo apt install luarocks is not the recommended installation approach. The APT version is a bit old (the 3.8.0 in Sept. 2025). But it's good enough for this plugin dependencies.

juanMarinero avatar Sep 19 '25 20:09 juanMarinero