Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
simonwiles opened this issue Mar 8, 2024 · 13 comments

Comments

@simonwiles
Copy link
Contributor

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
Copy link
Contributor

wmertens commented Mar 8, 2024

Look at your .git folder

@simonwiles
Copy link
Contributor Author

simonwiles commented Mar 8, 2024

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
Copy link
Contributor Author

simonwiles commented Mar 8, 2024

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
Copy link

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

@rosetintedcheeks
Copy link

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
Copy link

Probably this nodejs/node#52018

@simonwiles
Copy link
Contributor Author

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
Copy link

chneau commented Apr 22, 2024

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
Copy link

For me works just with node v18

Any other version gives me errors

@TobiTenno
Copy link

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

@AliAlmasi
Copy link

@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

@tumoxep
Copy link

tumoxep commented Jul 24, 2024

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

@campersau
Copy link
Collaborator

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) nodejs/node#53452

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants