gitbutlerapp / gitbutler

The GitButler version control client, backed by Git, powered by Tauri/Rust/Svelte
https://gitbutler.com
Other
12.46k stars 492 forks source link

Cannot add project when filetree contains a socket #3614

Open To1ne opened 4 months ago

To1ne commented 4 months ago

I tried to import my project, in the project directory there is a socket file (which is in the .gitignore) which is used to run the project locally. Having this socket in existence makes project import fail:

2024-04-26T08:44:54.072686Z  INFO add_project: gitbutler-app/src/projects/commands.rs:71: close time.busy=18.1s time.idle=50.0µs path="/home/toon/devel/gdk"
2024-04-26T08:46:30.743736Z  INFO add_project: gitbutler-app/src/projects/commands.rs:71: new path="/home/toon/devel/gdk"
2024-04-26T08:46:30.746217Z  INFO add_project: gitbutler-app/src/gb_repository/repository.rs:343: created new session project_id=b68db585-dcaa-4ec3-9a04-6ada8c80db80 session_id=0df76f79-4ce5-418e-a598-827132d46abd path="/home/toon/devel/gdk"
2024-04-26T08:46:46.720936Z ERROR add_project: gitbutler-app/src/projects/commands.rs:63: failed to add project error=failed to open repository

Caused by:
    0: failed to run initial flush
    1: failed to build working directory tree
    2: failed to build wd index
    3: failed to add working directory path gitlab.socket
    4: could not open '/home/toon/devel/gdk/gitlab.socket': No such device or address; class=Os (2) path="/home/toon/devel/gdk"
2024-04-26T08:46:46.720972Z  INFO add_project: gitbutler-app/src/projects/commands.rs:71: close time.busy=16.0s time.idle=41.0µs path="/home/toon/devel/gdk"

You can clone the project from https://gitlab.com/gitlab-org/gitlab-development-kit/, but you need to run the whole SDK to run into this, so I've created reproduction steps:

git init my-project
cd my-project
nc -lU my.socket

Try to import that, and you'll get "Something went wrong".


While I was testing this I noticed import seems to hang when you have a named pipe in your repo, created with mkfifi my.pipe.

Byron commented 4 months ago

Thanks for reporting!

It looks like you are on Windows and aren't using the latest version, 0.11.4 at the moment. There the issue you are describing should be fixed. Could you try to update and try again? Thank you.

To1ne commented 4 months ago

I'm on Linux. Maybe I wasn't using 0.11.4 at the time, but now I am. The log now shows:

2024-04-26T13:42:33.040736Z ERROR add_project: crates/gitbutler-tauri/src/projects.rs:27: error=Error(failed to add 'foo.socket' to temporary index

Caused by:
    0: failed to open repository
    1: failed to run initial flush
    2: failed to build working directory tree
    3: failed to build wd index
    4: failed to add 'foo.socket' to temporary index
    5: could not open '/tmp/tmp.PdmNlywACH/foo.socket': No such device or address; class=Os (2)) path="/tmp/tmp.PdmNlywACH"
2024-04-26T13:42:33.040780Z  INFO add_project: crates/gitbutler-tauri/src/projects.rs:27: close time.busy=16.7ms time.idle=57.7µs path="/tmp/tmp.PdmNlywACH"
Byron commented 4 months ago

Thanks you!

That's strange - foo.socket shouldn't be touched if it is ignored. If the .gitignore file contains foo.socket and git ignores it, then the answer must be some part of the code that doesn't respect .gitignore - I will take a look.

Qix- commented 4 months ago

I actually can't reproduce this on MacOS. Not only does our client ignore it, but even the Git CLI ignores it entirely, even without a .gitignore.

EDIT: This looks like a symlink, that's a clue. Let me check.


I still can't reproduce on Mac for some reason; I tried

This might be linux specific. I'm not sure why we'd be trying to open it, though, given that it's gitignored. That's really strange and doesn't seem like it'd be platform-specific.

A clue that this is a symlinked + closed (server is dead) socket is that the realpath gets resolved to /tmp and the error, No such device or address, means that the socket file exists but no endpoint (server) is responding on the other side.

We do have a bug, however, that GItButler will show a symlinked/hardlinked socket in the file tree erroneously, but it seems to be unaffected by commits (as it should be). Git CLI at least follows the symlink and tries to stat the file it points to when determining if the file should be ignored - we should be doing that for anything that isn't a Normal/Dir file node on *nix systems.

However that doesn't address the fact I still can't reproduce on Mac 😓 I'll have to try this on Linux when I get a chance.

jhult commented 4 months ago

Possibly related issues: #2608 and #2672