0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

NeoVim(LazyVim)の起動時にnvim-treesitterのエラーが出る場合の対処法

Last updated at Posted at 2025-12-11

はじめに

この記事はQiita Advent Calendar 2025 / ひとりアドベントカレンダー 分野における ふぐおの配信関係多めひとり Advent Calendar 2025 の12日目の記事となります。

こんにちは、ふぐおです。
LazyVimを使っているときに、nvim-treesitterのエラーによく遭遇したので解決策をシェアします。

エラー内容

LinuxでもWindowsでも発生する場合があります。
内容的には、各言語のパーサーのインストールがNeoVimの起動時に毎回走り、毎回失敗するという感じです。
Windows環境でパーサーのインストールに失敗する場合、以下のようなエラーが出ることがあります。

[nvim-treesitter/install/c] error: Error during "tree-sitter build": Warning: You have not configured any parser directories!
Please run `tree-sitter init-config` and edit the resulting
configuration file to indicate where we should look for
language grammars.


thread 'main' panicked at cli\src\main.rs:848:18:
called `Result::unwrap()` on an `Err` value: Failed to execute the C compiler with the following command:
"cl.exe" "-nologo" "-MD" "-O2" "-Brepro" "-std:c11" "-I" "C:\\Users\\pasca\\AppData\\Local\\Temp\\nvim\\tree-sitter-c\\src" "-W4" "-LD" "-utf-8" "C:\\Users\\pasca\\AppData\\Local\\Temp\\nvim\\tree-sitter-c\\src\\parser.c" "-link" "-out:C:\\Users\\pasca\\AppData\\Local\\Temp\\nvim\\tree-sitter-c\\parser.so"

Caused by:
    program not found
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

対処方法

1. Cコンパイラのインストール

WindowsもLinuxもCコンパイラが必要です。

Linux(Ubuntu)の場合

apt install build-essential

Windowsの場合
Visual StudioからCやC++のビルドツールをインストールすることをおすすめします。

Visual Studioのインストールをしたくない場合の方法については、以下のIssueを参照することをおすすめします。

2. Tree-sitter CLIのインストール

上記のコンパイラのインストールでも改善しない場合は、Tree-sitter CLIをインストールしてみてください。

インストール方法は以下の通りです。

npmやcargoなどでインストールできます。
インストール後に以下のコマンドを実行して設定ファイルを生成するのを忘れずに!

tree-sitter init-config
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?