how to fix the `error: bad fsmonitor version 2` in Windows Subsystem for Linux (WSL)?

Viewed 3765

I do have Git Bash installed (WSL2 is still very slow on large git repos like llvm and webkit). in WSL2 Ubuntu 20.04:

matt@Surface2:/mnt/c/Users/matt/src/roact-alignment$ git --version
git version 2.25.1

in cmd:

C:\Users\matt>git --version
git version 2.33.0.windows.1

even when no cmd is opened, I was getting this for git operations:

matt@Surface2:/mnt/c/Users/matt/src/roact-alignment$ git pull
error: bad fsmonitor version 2
error: bad fsmonitor version 2
4 Answers

I solved this problem by upgrading git.

# Add ppa of git
sudo add-apt-repository ppa:git-core/ppa

# Update sources
sudo apt update

# Upgrade git
sudo apt upgrade

more details, see this Page

I think in newer VS Code, it has the win32 git client running. It appears that the linux git client connects to the win32 fsmonitor "service" somehow.

The solution was to update the version of git in WSL2 to be closer to the git.exe that was installed with Git Bash and/or Visual Studio Code.

I followed the instructions to add the updated git releases PPA for Ubuntu here: https://git-scm.com/download/linux

and the messages went away!

You can (soon) try with Git 2.38 (Q3 2022), since "scalar" now enables built-in fsmonitor on enlisted repositories, when able, which speeds things up.
Since it also uses fsmonitor version 2, there should not be the initial error message (in addition of status/add/commit local operations being much faster).

See commit 8e28418, commit d934a11, commit 9b24bb9, commit d2a79bc, commit adedcee, commit 65f6a9e (18 Aug 2022) by Victoria Dye (vdye).
See commit ec4c231 (18 Aug 2022) by Johannes Schindelin (dscho).
See commit 3f1917d (18 Aug 2022) by Matthew John Cheetham (mjcheetham).
(Merged by Junio C Hamano -- gitster -- in commit bc820cf, 29 Aug 2022)

scalar: enable built-in FSMonitor on register

Helped-by: Junio C Hamano
Helped-by: Derrick Stolee
Signed-off-by: Matthew John Cheetham
Signed-off-by: Johannes Schindelin
Signed-off-by: Victoria Dye

Using the built-in FSMonitor makes many common commands quite a bit faster.
So let's teach the scalar register command to enable the built-in FSMonitor and kick-start the fsmonitor--daemon process (for convenience).

For simplicity, we only support the built-in FSMonitor (and no external file system monitor such as e.g. Watchman).

Example:

git init test/src
scalar register test/src &&
git -C test/src fsmonitor--daemon status

fixed by upgrade git to 2.36.1 in WSL2

Related