ungit icon indicating copy to clipboard operation
ungit copied to clipboard

`Error: ENOENT: no such file or directory, stat '/path/to/repo/.git/index.lock'`

Open simonwiles opened this issue 11 months ago • 10 comments

In the last couple of days ungit crashes every time I load it, with the error:

2024-03-08T03:57:20.668Z - error: Error: ENOENT: no such file or directory, stat '/path/to/repo/.git/index.lock'
    at statSync (node:fs:1659:25)
    at FSWatcher.<anonymous> (node:internal/fs/recursive_watch:160:28)
    at FSWatcher.emit (node:events:519:28)
    at FSWatcher._handle.onchange (node:internal/fs/watchers:215:12)
Stopped keeping ungit alive

Does anyone have any hints about how to begin debugging this?

simonwiles avatar Mar 08 '24 04:03 simonwiles

Look at your .git folder

wmertens avatar Mar 08 '24 11:03 wmertens

Thanks, yeah, perhaps I should have been more detailed :/

The .git folder has normal read/write permissions, and if I touch .git/index.lock then the ungit UI will load, but actions result in similar ENOENT errors for files ungit/git should be creating.

This just started in the last couple of days, for all my dozens and dozens of repos, all of which worked fine before and all of which still work fine from the normal git cli and all the other clients I've tried (the two others I use regularly are lazygit and the git integration in VS Code).

I'm assuming it's something that's changed on my system, as the ungit codebase hasn't changed, but I was hoping for a hunch about where to start from someone more experienced with this codebase. I'm on Arch so I have frequent updates to the latest versions of system libraries, so right now it seems like an update to something ungit depends on is probably the issue. I'll try to track it down, as ungit is unusable for me at present, and if it is a problem relating to an updated system dependency then it seems possible at least that this may affect other users in the future.

simonwiles avatar Mar 08 '24 17:03 simonwiles

Update: initial results suggest it may be a node 21 thing.

Everything works fine from inside a node:20-bookworm container, but fails inside a node:21-bookworm container. Confirmed that downgrading node to v20 works on my host OS too.

I'm not seeing anything immediately obvious in the Node 21 release announcement, but I am seeing a few folks posting what could be related issues.

Will update if/when I can work out exactly what's caused; for now I can work around by using the LTS version of Node, and return to this when I've got some work done for today :)

simonwiles avatar Mar 08 '24 18:03 simonwiles

This is specifically happening for me in node v21.7.0. Downgrading to v21.6.2 avoids the issue.

GunnerGuyven avatar Mar 11 '24 16:03 GunnerGuyven

I'm having the same issue on node v21.7.0 Downgrading to v21.6.2 has fixed the problem. I was also getting the error on .git/objects/maintenance.lock

2024-03-12T15:02:35.209Z - error: Error: ENOENT: no such file or directory, stat '***/.git/objects/maintenance.lock'
    at statSync (node:fs:1659:25)
    at #watchFile (node:internal/fs/recursive_watch:152:28)
    at #watchFolder (node:internal/fs/recursive_watch:129:26)
    at FSWatcher.<anonymous> (node:internal/fs/recursive_watch:179:26)
    at FSWatcher.emit (node:events:519:28)
    at FSWatcher._handle.onchange (node:internal/fs/watchers:215:12)
Stopped keeping ungit alive

rosetintedcheeks avatar Mar 12 '24 15:03 rosetintedcheeks

Probably this https://github.com/nodejs/node/issues/52018

rosetintedcheeks avatar Mar 12 '24 17:03 rosetintedcheeks

Just swinging back past to note that upgrading Node LTS (Iron) from v20.11 to v20.12 seems to have introduced the same problem (v20.11 works, v20.12 crashes with the same error).

Obviously a node issue not an ungit issue (and presumably/hopefully the one noted by @rosetintedcheeks that now has a fix PR) -- just noting this here for future travellers.

simonwiles avatar Apr 05 '24 16:04 simonwiles

As a workaround on Linux I have to downgrade node to 18

brew install node@18
brew link --overwrite node@18

Something else I tried and did not work is bunx --bun ungit that unfortunately returns plain text to the browser.

chneau avatar Apr 22 '24 10:04 chneau

For me works just with node v18

Any other version gives me errors

joaomelo-itau avatar May 16 '24 12:05 joaomelo-itau

for what it's worth, it stopped happening for me on v20.15 after it broke on v20.12

TobiTenno avatar Jun 22 '24 23:06 TobiTenno

@simonwiles I have the same problem, I just have to downgrade the node to fix this problem?

[ali@cxz cv]$ ungit
Setting log level to warn
## Ungit started ##

Took 445ms to start server.
Navigate to http://localhost:8448/#/repository?path=/home/ali/code/cv
2024-07-18T19:51:04.273Z - error: Error: ENOENT: no such file or directory, stat '/home/ali/code/cv/.git/index.lock'
    at statSync (node:fs:1659:25)
    at FSWatcher.<anonymous> (node:internal/fs/recursive_watch:160:28)
    at FSWatcher.emit (node:events:519:28)
    at FSWatcher._handle.onchange (node:internal/fs/watchers:215:12)
Stopped keeping ungit alive

AliAlmasi avatar Jul 18 '24 19:07 AliAlmasi

crashes on v20.15.1 But if I keep relaunching it's possible to make actions (one step at the time mostly)

upd: works like a charm on v20.16.0

tumoxep avatar Jul 24 '24 16:07 tumoxep

This was a node issue and has been fixed in https://github.com/nodejs/node/releases/tag/v20.16.0

[621e073c96] - fs: do not crash if the watched file is removed while setting up watch (Matteo Collina) https://github.com/nodejs/node/pull/53452

campersau avatar Aug 21 '24 07:08 campersau