FredrikNoren / ungit

The easiest way to use git. On any platform. Anywhere.
MIT License
10.41k stars 637 forks source link

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

Open simonwiles opened 3 months ago

simonwiles commented 3 months ago

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?

wmertens commented 3 months ago

Look at your .git folder

simonwiles commented 3 months ago

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 commented 3 months ago

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 :)

GunnerGuyven commented 3 months ago

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

rosetintedcheeks commented 3 months ago

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 commented 3 months ago

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

simonwiles commented 3 months ago

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.

chneau commented 2 months ago

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.

joaomelo-itau commented 1 month ago

For me works just with node v18

Any other version gives me errors

TobiTenno commented 1 week ago

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