Repository navigation
Cannot find luarocks to install treesitter modules #1809
Description
Prerequisites
- I am using the latest stable release of Neovim
- I am using the latest version of the plugin
Neovim Version
NVIM v0.12.1 Build type: Release LuaJIT 2.1.1774638290
Neorg setup
require("neorg").setup({
load = {
["core.esupports.metagen"] = {
config = {
author = "Matteo Golin",
},
},
["core.defaults"] = {},
["core.qol.toc"] = { config = { close_after_use = true } },
["core.completion"] = { config = { engine = "nvim-cmp" } },
["core.summary"] = {},
["core.concealer"] = { config = { icons = { code_block = { conceal = true, width = 80 } } } },
["core.export"] = {},
["core.looking-glass"] = {},
["core.presenter"] = { config = { zen_mode = "zen-mode" } },
["core.integrations.telescope"] = {},
["core.integrations.treesitter"] = {},
["core.ui"] = {},
["core.tempus"] = {},
["core.ui.calendar"] = {},
["core.export.markdown"] = { config = { extensions = "all" } },
["core.journal"] = {
config = {
journal_folder = "journo",
},
},
["core.dirman"] = {
config = {
workspaces = {
junk = "~/notes/junk",
school = "~/notes/school",
projects = "~/notes/projects",
cuinspace = "~/notes/cuinspace",
},
default_workspace = "junk",
},
},
["core.keybinds"] = {
config = {
hook = function(keybinds)
keybinds.remap_event("norg", "n", "<LocalLeader>z", "core.looking-glass.magnify-code-block")
keybinds.map("norg", "n", "<LocalLeader>p", "<Cmd>Neorg presenter start<CR>")
keybinds.map("norg", "n", "<leader>fnh", "<Cmd>Telescope neorg search_headers<CR>")
keybinds.map("norg", "n", "<leader>fnl", "<Cmd>Telescope neorg find_linkable<CR>")
keybinds.map("norg", "n", "<LocalLeader>il", "<Cmd>Telescope neorg insert_file_link<CR>")
keybinds.remap_event("norg", "n", "]l", "core.integrations.treesitter.next.link")
keybinds.remap_event("norg", "n", "[l", "core.integrations.treesitter.previous.link")
keybinds.remap_event("norg", "n", "]h", "core.integrations.treesitter.next.heading")
keybinds.remap_event("norg", "n", "[h", "core.integrations.treesitter.previous.heading")
end,
},
},
},
})Actual behavior
This is the error I receive when I open Neovim. I have installed the Lua for Windows package and luarocks is on the system path and is executable. I am not sure why the build process cannot find it.
I have also tried the luarocks.nvim package, which fails with this mysterious error:
Unable to load the luarocks package loader. Try re-running the build stage (`:Lazy build luarocks.nvim`). Full trace: ...\lazy\luarocks.nvim\.rocks\lua\luarocks\core\persist.
lua:5: module 'dkjson' not found:
no field package.preload['dkjson']
cache_loader: module 'dkjson' not found
cache_loader_lib: module 'dkjson' not found
no file '.\dkjson.lua'
no file 'C:\Program Files\Neovim\bin\lua\dkjson.lua'
no file 'C:\Program Files\Neovim\bin\lua\dkjson\init.lua'
no file 'C:\Program Files (x86)\Lua\5.1\lua\dkjson.luac'
no file 'C:\Users\matte\AppData\Local\nvim-data/lazy-rocks/telescope.nvim/share/lua/5.1/dkjson.lua'
no file 'C:\Users\matte\AppData\Local\nvim-data/lazy-rocks/telescope.nvim/share/lua/5.1/dkjson/init.lua'
no file 'C:\Users\matte\AppData\Local\nvim-data/lazy-rocks/tree-sitter-norg/share/lua/5.1/dkjson.lua'
no file 'C:\Users\matte\AppData\Local\nvim-data/lazy-rocks/tree-sitter-norg/share/lua/5.1/dkjson/init.lua'
no file 'C:\Users\matte\AppData\Local\nvim-data/lazy-rocks/tree-sitter-norg-meta/share/lua/5.1/dkjson.lua'
no file 'C:\Users\matte\AppData\Local\nvim-data/lazy-rocks/tree-sitter-norg-meta/share/lua/5.1/dkjson/init.lua'
no file 'C:\Users\matte\AppData\Local\nvim-data/lazy-rocks/pathlib.nvim/share/lua/5.1/dkjson.lua'
no file 'C:\Users\matte\AppData\Local\nvim-data/lazy-rocks/pathlib.nvim/share/lua/5.1/dkjson/init.lua'
no file 'C:\Users\matte\AppData\Local\nvim-data/lazy-rocks/neorg/share/lua/5.1/dkjson.lua'
no file 'C:\Users\matte\AppData\Local\nvim-data/lazy-rocks/neorg/share/lua/5.1/dkjson/init.lua'
no file 'C:\Users\matte\AppData\Local\nvim-data\lazy\luarocks.nvim\.rocks\share\lua\5.1\dkjson.lua'
no file 'C:\Users\matte\AppData\Local\nvim-data\lazy\luarocks.nvim\.rocks\share\lua\5.1\dkjson\init.lua'
no file 'C:\Users\matte\AppData\Local\nvim-data\lazy\luarocks.nvim\.rocks\lua\dkjson.lua'
no file 'C:\Users\matte\AppData\Local\nvim-data\lazy\luarocks.nvim\.rocks\lua\dkjson\init.lua'
no file '.\dkjson.dll'
no file 'C:\Program Files\Neovim\bin\dkjson.dll'
no file 'C:\Program Files\Neovim\bin\loadall.dll'
no file 'C:\Users\matte\AppData\Local\nvim-data/lazy-rocks/telescope.nvim/lib/lua/5.1/dkjson.dll'
no file 'C:\Users\matte\AppData\Local\nvim-data/lazy-rocks/telescope.nvim/lib64/lua/5.1/dkjson.dll'
no file 'C:\Users\matte\AppData\Local\nvim-data/lazy-rocks/tree-sitter-norg/lib/lua/5.1/dkjson.dll'
no file 'C:\Users\matte\AppData\Local\nvim-data/lazy-rocks/tree-sitter-norg/lib64/lua/5.1/dkjson.dll'
no file 'C:\Users\matte\AppData\Local\nvim-data/lazy-rocks/tree-sitter-norg-meta/lib/lua/5.1/dkjson.dll'
no file 'C:\Users\matte\AppData\Local\nvim-data/lazy-rocks/tree-sitter-norg-meta/lib64/lua/5.1/dkjson.dll'
no file 'C:\Users\matte\AppData\Local\nvim-data/lazy-rocks/pathlib.nvim/lib/lua/5.1/dkjson.dll'
no file 'C:\Users\matte\AppData\Local\nvim-data/lazy-rocks/pathlib.nvim/lib64/lua/5.1/dkjson.dll'
no file 'C:\Users\matte\AppData\Local\nvim-data/lazy-rocks/neorg/lib/lua/5.1/dkjson.dll'
no file 'C:\Users\matte\AppData\Local\nvim-data/lazy-rocks/neorg/lib64/lua/5.1/dkjson.dll'
no file 'C:\Users\matte\AppData\Local\nvim-data\lazy\luarocks.nvim\.rocks\lib\lua\5.1\dkjson.dll'
I did try rerunning the build, and also tried installing luarocks install dkjson to see if that would help. No luck.
Expected behavior
Tree sitter modules are installed and everything is fine!
This is new behaviour since updating Neovim packages.
Steps to reproduce
Open Neovim with the aforementioned Neorg setup and observe that Lazy fails to install the tree-sitter modules.
Potentially conflicting plugins
I think this is self-contained with Neorg's build process failing to obtain luarocks.
Other information
I am using Windows 11 on an ARM64 device. The Lua 5.1 interpreter is on the path, as is the luarocks install I got via Lua for Windows. I performed the install with all options checked (C libraries and headers included).
Help
No
Implementation help
No response
Activity
linguini1 commentedon Jun 9, 2026
I fixed the dkjson problem by adding that to the
rocksarray, but the rest of the problem persists: luarocks cannot be spawned during the build of the treesitter modules.I ran
checkhealth neorgand it says it can see luarocks just fine. No clue how to fix this.Ciliane commentedon Jun 15, 2026
I'm on windows, I had issues with the treesitter modules building after that update as well. Trying to solve all the issues I had trying to get neorg to work again was a bit hellish, but it's over now!
There was actually a whole series of issues on the way to making it work. The problem described in this issue is the first step. lua-for-windows creates a
luarocks.bat(or .cmd) in your path which then runs lua to run luarocks, and normally just enteringluarocksin the terminal would find that bat file and execute it similarly to as if it was an exe, but the process spawn function that Lazy uses doesn't find that good enough and wants aluarocks.exeto be on your path specifically. What you should do is actually not use lua-for-windows anymore, because it ships an outdated version of luarocks that is too old for the version of .rockspec that norg treesitter modules are now using (3.0+). You can probably get it anywhere you want, I personally got it by installinglua,lua51(you need to enable theversionsbucket to get that) andluarocksScoop packages. I also renamed thelua51shims tolua5.1because that's the name luarocks looks for when it's looking for that version. That version of luarocks happens to provide aluarocks.exeso that also works for solving the very first issue, but if you get it from somewhere else and it only has a .bat or .cmd, you can use this to make a shim https://github.com/ScoopInstaller/ShimThe solution to the first problem I tried first was to just make a shim to the
luarocks.batthat was provided by lua-for-windows. That solved the problem with Lazy not being able to find luarocks, but it runs into a problem that is very sneaky and lacking obvious cause. Build cyclically fails with an error that doesn't tell you much ("nvim-data/lazy/lazy-rocks/tree-sitter-norg/lua/5.1/whatever-i-forgot command doesn't exist") until Lazy gives up on build after too many attempts. I can't be sure what was going on there exactly, but it must be something to do with the version of luarocks that is shipped with lua-for-windows being too old because this problem just went away when I tried using the scoop packages instead of lua-for-windows.The next problem is at least the most descriptive as it actually gives you some logs of the build process in the Lazy installer. The lines I thought are the most relevant -
No such file or directory "x86_64-w64-mingw32-gcc"andx86_64-w64-mingw32-gcc -O2 -c -o src/parser.o src/parser.c -Isrc -Isrc -shared. I don't have somex86_6ahdfuiehaoufeh-gccon my path so I was puzzled by where it got that from, but I eventually found that the treesitter build backend of luarocks just couldn't find my C/C++ compiler (I just installed thegccscoop package if that matters, but that has been good enough for everything else so I don't know why this is different) and this was possibly it's fallback command. I found that at least one way you can solve this is to set upCCandCXXenvironment variables. In a powershell running, the quick and dirty solution was to run$env:CC = "path_to_gcc"and$env:CXX = "path_to_g++"before nvim, and after that the treesitter things finally got properly built! I'll need to find a more permanent and solid solution to make luarocks find the compilers than that, but I'll do that later and at least you can finally build this wayThe last, kind of cosmetic problem, is the warning you get at launch that says "norg_treesitter parser was not found! many plugin features will not work", it's kind of just wrong because everything still works, but the solution here #1808 (comment) works to shut it up
linguini1 commentedon Jun 15, 2026
@Ciliane thanks for your help! This has gotten me farther.
However, I am now getting a new error when building:
This appears to also happen if I run
luarocks config --lua-version=5.1.Did you encounter this issue, or any ideas?
Ciliane commentedon Jun 15, 2026
yeah, I also had that error line at the top of the error log at the step where it was attempting to compile the parser, where the issue was that the C++ luarocks for some reason couldn't locate compilers by itself. Can you look at more of that log to see if it has something similar to
C:\Users\User\scoop\apps\lua\current\lua5.1.exe: cannot open e -e io.write(_VERSION:sub(5)) : No such file or directory "x86_64-w64-mingw32-gcc"? If you do you probably have the same problem I had at this stage, and you should be able to solve it by settingCCandCXXenvironment variables to point to your C and C++ compilers. If it's not actually that then I'm not sure what it could be, would have to see the entire build log to make a guessAlso I have that error appear when running
luarocks configwith--lua-versiontoo, I think you can ignore it because I got neorg working despite it so it wasn't critical. So I think that error appearing in the Lazy build log is basically irrelevant and the real error that ruins the build is something else, likely luarocks not knowing where the compiler islinguini1 commentedon Jun 15, 2026
Here's the full build log from Lazy:
I have set my CC and CXX env variables to point at my mingw installation of gcc and g++.
From reading this, it appeared the system is missing luafilesystem (even though it says it installed it afterward in the lazy-rocks). I tried installing it myself:
This error, as far as I can tell from my checking online, is because the compiler I'm using is not the same as the one used to make the lua5.1.dll in the first place. Anyways, this does look like a compiler issue, but I'm not quite sure how to resolve it. Maybe another version of gcc? If it makes a difference, I am running on an arm64 Windows machine which is maybe adding some complications here.
zwiebelbox commentedon Jun 16, 2026
I got the same issue after following the kickstart guide on Windows. Just a reminder to update the recommendation for installing luarocks when you find a better solution. Or put a note with a link to this thread for now.
Ciliane commentedon Jun 16, 2026
@linguini1 indeed it looks like a different kind of issue here. for me it was enough just to have luarocks know where my compiler is so that it can compile, but for you it seems like the issues continue a bit further. I don't know what to do at this point, someone actually knowledgeable about this stuff compiling C/C++ programs probably would be able to help here but I can't, sorry. Different architecture potentially being the cause makes sense, but doesn't give me ideas about what to do except see if you can compile that lua dll and everything yourself (lol). Unfortunate, hope there's someone more knowledgeable who can give a hint or you can figure it out somehow
(edit: I suppose if you want to you can try it with gcc from its scoop pakage or msys2 to make really sure. I'm not sure what that would change, but maybe it'd magically work)
@zwiebelbox have you managed to fix it?
zwiebelbox commentedon Jun 16, 2026
To be clear, I got the original error that luarocks is not found even though it's accessible in the terminal and via
:! luarocks. I just searched the repo for a solution and found this thread. I haven't reproduced the error that @linguini1 got.I'm attempting a local installation without admin rights.
I referenced the luarocks repo and it might be possible via the single binary package if you already have lua but then the recommendation for new users would be "install lua for windows and then go to this repo, download a binary and put it into your lua directory" - a bit messy.
The main issue seems to be that lua for windows doesn't update their luarocks version, so I wondered if there's an issue open for that. I couldn't find one, but they have an open issue about updating the lua version where the solution seems to be to just use scoop package manager instead of their own repo as you mentioned as well. I will check it out later.
zwiebelbox commentedon Jun 17, 2026
What I did:
But I seem to get the same error as @linguini1
lazy displays the following:
I tried setting my lua interpreter:
And an error window pops up as well:
But as you can see, scoop configures lua correctly:
The issue is caused by the parsed extra
eand seems to be a known issue of luarocks on Windows. The attempted fix was reverted because it caused problems in testing. So I don't really understand how you got it to work on your own Windows machine without a local fix or something.nvim also displays these errors on startup but following the kickstart guide, I just ignored them for now:
zwiebelbox commentedon Jun 17, 2026
Reading this again, I should focus more on the errors I ignored. Not finding .h files should indeed be an issue with C/C++ paths.
EDIT: yeah, just installing gcc via scoop (as a quick and dirty fix - I should already have it somewhere else) got rid of most of the errors popping up. I think it said nvim-treesitter installed correctly.
But on startup it still says:
And tree-sitter-norg (and -meta) are still failing their builds
zwiebelbox commentedon Jun 17, 2026
After
:TSInstall norg, only the error withnorg_meta treesitter parser was not found! Many plugin features will not work.shows up un startup. The lazyvim errors are still there. I can't find the norg meta parser this way though. Tried a couple of variants.Btw, the kickstart guide assumes that the user doesn't have a prior neovim configuration, but it doesn't mention anything about its installation. On Windows you can
scoop install neovimas well. That's what I'm using now.Also, I wonder why the splash screen disappeared. You can see what I'm referencing by executing
nvim --clean.linguini1 commentedon Jun 17, 2026
So your solution was installing gcc from scoop? Does that conflict with your regular MinGW gcc?
zwiebelbox commentedon Jun 17, 2026
Actually it does.. It worked right after installing gcc with scoop but in a new terminal, the old MinGW gcc is found before the scoop installation. I guess I have to set the path properly.
Not sure if I continue though - might revisit neorg after lux is ready to replace luarocks.
Ciliane commentedon Jun 17, 2026
I may have been wrong about having a shim named
lua5.1being enough because at some point I also manually edited luarocks's config file (scoop\apps\luarocks\current\config.lua) to setlua_versionto 5.1, andvariables.LUA_DIRandvariables.LUA_BINDIRto point to the lua51 installation, because setting those things throughluarocks configdidn't seem to work becauese of those errors. I believed that thing I did would've been reverted because I uninstalled all the lua things at some point and later tried again more "clean", so I thought this wasn't a part of the progress I made. It possibly was, so it'd be good to mention...if you have the parsers install correctly but then sometimes see these messages in startup, that's a different issue reported here with some solutions #1808 . For me the one that worked was to add tree-sitter-norg and tree-sitter-norg-meta as dependencies of norg, after that those warnings don't appear anymore. So did they really build for you properly now? Lazy managed to finish the build and isn't attempting to do it on each startup anymore? Does that mean installing a different gcc actually turned out to be the magic solution in your case?