nvimdots
nvimdots copied to clipboard
nvim-treesitter[latex]: Error during compilation
Version confirmation
- [X] Confirm
Following prerequisites
- [X] Confirm
Not a user config issue
- [X] Confirm
Neovim version
NVIM v0.10.0
Operating system/version
Linux VM-32-9-opencloudos 6.6.30-4.oc9.x86_64
Terminal name/version
iTerm2
$TERM environment variable
xterm-256color
Branch info
0.10 (Nightly)
Fetch Preferences
SSH (use_ssh = true)
How to reproduce the issue
- using flake.nix
- nvim
Expected behavior
No Error
Actual behavior
bottom line:
- nvim-treesitter[latex]
- [nvim-treesitter] [0/1] Generating source files from grammar.js...
nvim-treesitter[latex]: Error during compilation
cc1: fatal error: src/parser.c: No such file or directory
compilation terminated.
src/scanner.c:4:10: fatal error: tree_sitter/parser.h: No such file or directory
4 | #include <tree_sitter/parser.h>
| ^~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Additional information
No response
Have u installed the tree-sitter CLI tool as per Wiki:Prerequisites#optional-packages?
Thank you for your reply.
The issue persists even after I installed tree-sitter.
$ which tree-sitter
~/.nix-profile/bin/tree-sitter
I switched to a brand new system, Ubuntu 24.04 TLS, and did a fresh installation. This time, I didn't interrupt nvim during its first startup, and it finally succeeded.
[nvim-treesitter] [1/1] Treesitter parser for latex has been installed.
I suspect that interrupting nvim during its first startup previously may have caused some intermediate state issues?
You can continue the installation process by :TSUpdate.
You can continue the installation process by
:TSUpdate.
I have used this method before, but it didn't work, the issue persists.
in branch 0.10 should include https://github.com/ayamir/nvimdots/blob/07a165b3fe16494dbb6616c6c0d4dc247afb50dc/nixos/neovim/default.nix#L173 already.
it weird to see the error shows the parser is still missing. maybe @misumisumi can help?
How do you run neovim on nix (home-manager or NixOS)
Standalone neovim probably won't work well.
Try the following if you can use nix command.
Clone this repo and enter to dev env with running nix develop and run nvim.
Then check if tree-sitter compiles.
How do you run neovim on nix (
home-managerorNixOS) Standalone neovim probably won't work well.Try the following if you can use
nixcommand. Clone this repo and enter to dev env with runningnix developand runnvim. Then check if tree-sitter compiles.
Yes, I use home-manager install the pkg tree-sitter & neovim. I'll have a try
just install tree-sitter and tree-sitter-cli
just install tree-sitter and tree-sitter-cli
his using our nixpkgs config, so tree-sitter should be installed.
his using our
nixpkgsconfig, sotree-sittershould be installed.
During the morning, when I was installing the computer for my friend, I also encountered this issue.
just install
tree-sitterandtree-sitter-cli
It is the solution I came up with at that time lol
r u also using nixpkgs/home-manager?
Sorry, I didn't realize using nix
tree-sitter is already installed.
I don't think it's necessary to install anything additionally...
tree-sitter is not needed globally, so it can only be run from within neovim.
I've encountered a similar error regardless of whether tree-sitter is installed manually:
nvim-treesitter[latex]: Error during compilation
cc: error: src/parser.c: No such file or directory
Press ENTER or type command to continue
I'm still not sure about the specific cause, and it doesn't always reproduce. If there are no other reports for a while, I think it can be closed.
it doesn't always reproduce.
What does this mean? Does this mean that the problem may also occur or not occur on home-manager?
it doesn't always reproduce.
What does this mean? Does this mean that the problem may also occur or not occur on home-manager?
I've encountered this issue a few times, but sometimes I am unable to reproduce it, which does indeed conflict with the reproducibility aspect of Nix, but I'm not sure what the cause is.
I've encountered a similar error regardless of whether tree-sitter is installed manually:
@kevin1sMe No, these are separate issues. This issue (https://github.com/ayamir/nvimdots/issues/1314#issuecomment-2201953801) happens bc there's a problem downloading the parser's source code[^1] (i.e., the C compiler couldn't locate parser.c). On the user side, Treesitter needs to compile parser.c into a shared library. This is where https://github.com/ayamir/nvimdots/issues/1314#issue-2381616549 occurred, as the C compiler couldn't find the required header(s).
[^1]: To be precise, the source is in JavaScript, and it's up to the plugin author to compile it into parser.c and include it with other assets.
Why wouldn't it recover during the next execution? Or why doesn't it redownload? Other parsers download normally; this one frequently has issues.
I've encountered a similar error regardless of whether tree-sitter is installed manually:
@kevin1sMe No, these are separate issues. This issue (#1314 (comment)) happens bc there's a problem downloading the parser's source code1 (i.e., the C compiler couldn't locate
parser.c). On the user side, Treesitter needs to compileparser.cinto a shared library. This is where #1314 (comment) occurred, as the C compiler couldn't find the required header(s).Footnotes
- To be precise, the source is in JavaScript, and it's up to the plugin author to compile it into
parser.cand include it with other assets. ↩
Why wouldn't it recover during the next execution? Or why doesn't it redownload?
If u meant to install that automatically, the best way is to add it to the ensure_installed list. However, if Treesitter isn't reinstalling parsers after a failed download, it's usually because a corrupted Git repo is still technically a repo (simply checking if the folder exists doesn't reveal if it's broken). The only way to reinstall is to delete the specific parser's source code folder and then restart Neovim.
Other parsers download normally; this one frequently has issues.
afaik latex is the only commonly-used parser that needs to be compiled from its grammar. This involves more than just compiling from a single C source code; u need the entire Treesitter library. If u don't need this parser, just leave it out of the ensure_installed list. Otherwise, u can try executing the following:
git clone --depth 1 https://github.com/latex-lsp/tree-sitter-latex.git \
&& cd tree-sitter-latex \
&& tree-sitter generate \
&& make CFLAGS='-v'
Upon successful compilation, u should see something like this:
/usr/bin/clang -v -Isrc -std=c11 -fPIC -c -o src/scanner.o src/scanner.c
ar rcs libtree-sitter-latex.a src/scanner.o
/usr/bin/clang -dynamiclib -Wl,-install_name,/usr/local/lib/libtree-sitter-latex.0.dylib,-rpath,@executable_path/../Frameworks src/scanner.o -o libtree-sitter-latex.dylib
sed -e 's|@URL@|https://github.com/latex-lsp/tree-sitter-latex|' \
-e 's|@VERSION@|0.3.0|' \
-e 's|@LIBDIR@|/usr/local/lib|' \
-e 's|@INCLUDEDIR@|/usr/local/include|' \
-e 's|@REQUIRES@||' \
-e 's|@ADDITIONAL_LIBS@||' \
-e 's|=/usr/local|=${prefix}|' \
-e 's|@PREFIX@|/usr/local|' bindings/c/tree-sitter-latex.pc.in > tree-sitter-latex.pc
Exactly one static and one dynamic library will be generated in the current working directory, named libtree-sitter-latex.[a/so/dylib]. If the build process somehow fails, u'll need to debug it urself, as there must be something wrong with ur build system.
In my environment, the above command will result in an error as reported. However when building from nvim-treesitter (i.e. mentioned in ensure_installed) it builds successfully. I don't know if nvim-treesitter is running a different command or building with different logic. I don't know if parser.c exists somewhere in the nix environment or if treesitter-cli is solving it.
In my environment, the above command will result in an error as reported.
Oops, sorry it looks like I accidentally removed one command. Here's the correct version:
git clone --depth 1 https://github.com/latex-lsp/tree-sitter-latex.git \
&& cd tree-sitter-latex \
&& tree-sitter generate \
&& make CFLAGS='-v'
I don't know if nvim-treesitter is running a different command or building with different logic.
Yes, internally nvim-treesitter calls the actual Treesitter API (libtree-sitter.so) to generate the necessary include files, similar to the tree-sitter generate command mentioned in https://github.com/ayamir/nvimdots/issues/1314#issuecomment-2208551619.
I don't know if parser.c exists somewhere in the nix environment or if treesitter-cli is solving it.
This shouldn't be a problem on our end since parser.c is supposed to be generated by the parser author and included in the repo. Check out https://tree-sitter.github.io/tree-sitter/creating-parsers#dependencies lol
if treesitter-cli is solving it
treesitter-cli simply copies the necessary headers and configurations to the build directory, nothing more.
treesitter-cli simply copies the necessary headers and configurations to the build directory, nothing more.
I confirmed that it was indeed copied under tree-sitter-latex/src. Hmm. Looking at what has been said so far, I am a little wondering if this is a problem in the NIX environment.
@kevin1sMe
What version of home-manager are you using?.
Also, if possible, could you please share the settings for programs.neovim.nvimdots?
Also, does https://github.com/ayamir/nvimdots/issues/1314#issuecomment-2208551619 succeed when executed from neovim's terminal?
This part is especially important.
Hmm. Looking at what has been said so far, I am a little wondering if this is a problem in the NIX environment.
Same here, it really looks like an issue with the author's build system.
programs.neovim.nvimdots
Do you mean this setting?
{pkgs, ...}:
{
programs.neovim.nvimdots = {
enable = true;
setBuildEnv = true; # Only needed for NixOS
withBuildTools = true; # Only needed for NixOS
};
}
Thank you. I just wanted to check.