threads / discuss / 57707

Issue when using the fsmonitor-watchman hook?

Subject: Issue when using the fsmonitor-watchman hook?

## tl;dr

3 messages between Apr 10, 2022 and Apr 12, 2022.

replies: 2people: 2as markdown or json

Kaartic Sivaraam· Apr 10, 2022, 18:21 UTC · lore
Hi all,

I recently installed v2.36.0-rc1 and started getting the warning about the deprecation of core.useBuiltinFSMonitor configuration. It appeared for each 'git' invocation which was a bit annoying. Fortunately, I had some spare time so I went the route of actually applying the suggested alternative rather than suppressing the warning.

According to the git-hooks documentation, I configured core.fsmonitor to '.git/hooks/fsmonitor-watchman' and after that for some reason all the styles in the terminal seems to have gone awry (I use Windows Terminal with PowerShell 7). A sample demonstration.

This is how the terminal should've looked (it appears with appropriate colours):

   04-10 23:36:38 D:\Source\kaartic\git [(f2817c1...) +2 ~0 -0 !]
 >

After setting the config the following is how it got rendered (without colours):

←[95m04-10 23:36:20 ←[0mD:\Source\kaartic\the-wallet 
←[93m[←[0m←[96mmaster←[0m←[96m ≡←[0m←[31m←[49m +1←[0m←[31m←[49m 
~0←[0m←[31m←[49m -0←[0m←[31m !←[0m←[93m]←[0m
 > cd ..\git\

I should note that I use posh-git [2] plug-in for the colourized Git metadata info in the terminal.

Also, I got the following error messages when running 'git status'
 > git status
open2: exec of watchman -j --no-pretty failed: No such file or directory 
at .git/hooks/fsmonitor-watchman line 78.
Unsupported query-fsmonitor hook version '1'.
Falling back to scanning...
On branch master
Your branch is up to date with 'origin/master'.
...

It's clear that I'm doing something wrong. I'm not sure what, though. The fact that I have no clear idea about what the fsmonitor-watchman hook does, does not help at all. It would be great if someone could help me understand what I got wrong :)

[1]: https://git-scm.com/docs/githooks#_fsmonitor_watchman [2]: https://github.com/dahlbyk/posh-git

-- 
Sivaraam
Derrick Stolee· Apr 11, 2022, 13:46 UTC · re: Kaartic Sivaraam · lore

Re: Issue when using the fsmonitor-watchman hook?

On 4/10/2022 2:21 PM, Kaartic Sivaraam wrote:
> Hi all,
Hi Kaartic,
 
Show 5 quoted lines
> I recently installed v2.36.0-rc1 and started getting the warning about
> the deprecation of core.useBuiltinFSMonitor configuration. It appeared
> for each 'git' invocation which was a bit annoying. Fortunately, I had
> some spare time so I went the route of actually applying the suggested
> alternative rather than suppressing the warning.

So, the new alternative is to set core.fsmonitor=true, which continues to use the builtin FS Monitor. What advice did you see that was different?

(Also, this thread will only apply to Git for Windows, since core Git did not include core.useBuiltinFSMonitor. Feel free to move this discussion to [1] if you'd rather talk there.)

[1] https://github.com/git-for-windows/git/discussions/3251
Hopefully using core.fsmonitor=true solves your issue.
---

If you really want to use the Watchman-based hook solution, then here's the rest of my response:

> According to the git-hooks documentation, I configured core.fsmonitor
> to '.git/hooks/fsmonitor-watchman' and after that for some reason all
> the styles in the terminal seems to have gone awry (I use Windows
> Terminal with PowerShell 7). A sample demonstration.

The hooks documentation will only discuss the external hook-based FS Monitor, not the builtin one, so you are changing your behavior here.

> Also, I got the following error messages when running 'git status'
> 
>> git status
> open2: exec of watchman -j --no-pretty failed: No such file or directory at .git/hooks/fsmonitor-watchman line 78.
> It's clear that I'm doing something wrong. I'm not sure what, though.
> The fact that I have no clear idea about what the fsmonitor-watchman
> hook does, does not help at all. It would be great if someone could
> help me understand what I got wrong :)

The .git/hooks/ directory is populated when your repository is created. That hook might not have existed in your installed templates when your repo was initialized.

Further, the default name is "fsmonitor-watchman.sample" and you need to change the name (after inspecting the script to ensure it is not malicious). You can also find the latest copy in a more protected place: C:\Program Files\Git\mingw64\share\git-core\templates\hooks

The .NET version of Scalar used to update the hook from this protected directory on upgrade. With the builtin mechanism, such efforts are not necessary.

Thanks, -Stolee

Kaartic Sivaraam· Apr 12, 2022, 19:27 UTC · re: Derrick Stolee · lore

Re: Issue when using the fsmonitor-watchman hook?

Hi Stolee,
On 11/04/22 19:16, Derrick Stolee wrote:
Show 11 quoted lines
>   
>> I recently installed v2.36.0-rc1 and started getting the warning about
>> the deprecation of core.useBuiltinFSMonitor configuration. It appeared
>> for each 'git' invocation which was a bit annoying. Fortunately, I had
>> some spare time so I went the route of actually applying the suggested
>> alternative rather than suppressing the warning.
> 
> So, the new alternative is to set core.fsmonitor=true, which continues
> to use the builtin FS Monitor. What advice did you see that was
> different?
> 
Ah ha. I should've guessed that. The actual advice I saw was the following:
   hint: core.useBuiltinFSMonitor will be deprecated soon; use 
core.fsmonitor instead
   hint: Disable this message with "git config 
advice.useCoreFSMonitorConfig false"

Rather than trying out configuring 'core.fsmonitor' to 'true', I went and took a look at the documentation for it in git-config [doc] which read as follows:

   If set, the value of this variable is used as a command which will
   identify all files that may have changed since the requested
   date/time.

That made me think the value could only be a command. So, it never occurred to me that it could be a boolean. I just checked the local doc that shows up when running `git config --help` in Windows and that seems to clearly mention the behaviour that setting to `true` would enable the built-in file system monitor. Looks like I made a mistake and referred to the doc for v2.35.2 when trying out the v2.36.0-rc2 x-<

[doc]: https://git-scm.com/docs/git-config#Documentation/git-config.txt-corefsmonitor

Show 8 quoted lines
> (Also, this thread will only apply to Git for Windows, since core Git
> did not include core.useBuiltinFSMonitor. Feel free to move this
> discussion to [1] if you'd rather talk there.)
> 
> [1] https://github.com/git-for-windows/git/discussions/3251
> 
> Hopefully using core.fsmonitor=true solves your issue.
>
Yeah. That works fine and suppresses the warning properly. Thanks!
> 
> If you really want to use the Watchman-based hook solution, then
> here's the rest of my response:
>
 > ...

I do wish to try out Watchman but not right now. For now, I suppose I'm fine with whatever the builtin fsmonitor does. Anyways, thanks for the details!

-- 
Sivaraam

← back to recent threads