gitbutlerapp / gitbutler

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

Error: Repo path is not owned by current user #4135

Closed Nicolas-Innocent closed 4 months ago

Nicolas-Innocent commented 4 months ago

Version

0.12.5

Operating System

Windows

Distribution Method

msi (Windows)

Describe the issue

image

Hi, I'm guessing this is due to the fact the code is on a linux VM and my windows machine just connects through samba. works perfectly fine for vs code.

I fully understand if this is not supported as it becomes more complicated to detect file changes on a network drive, but it would at least merit a clearer error message ?

How to reproduce

open a git repo hosted on a network drive.

Expected behavior

either to work (abait with higher latency, or even on manual refresh), or to at least give a better error message (This is not supported on network drives because .....)

Relevant log output

[2024-06-20][15:37:47][ERROR][webview::unknown] Unhandled exception: Error: Repository path 'S:/web/servers/hyperion/' is not owned by current user; class=Config (7); code=Owner (-36) undefined

2024-06-20T16:12:38.143883Z  INFO crates\gitbutler-tauri\src/main.rs:87: starting app version=0.12.5 name=GitButler
2024-06-20T16:12:38.276919Z  INFO get_user: crates\gitbutler-tauri\src\users.rs:12: new
2024-06-20T16:12:38.277006Z  INFO get_user: crates\gitbutler-tauri\src\users.rs:12: close time.busy=59.5µs time.idle=28.4µs
2024-06-20T16:12:38.279313Z  INFO list_projects: crates\gitbutler-tauri\src\projects.rs:40: new
2024-06-20T16:12:38.279554Z  INFO list_projects: crates\gitbutler-tauri\src\projects.rs:40: close time.busy=224µs time.idle=17.9µs
2024-06-20T16:12:38.443659Z  INFO get_project: crates\gitbutler-tauri\src\projects.rs:31: new id=65232218-b913-4d5d-97e2-9a99e461cf68
2024-06-20T16:12:38.447488Z  INFO get_project: crates\gitbutler-tauri\src\projects.rs:31: close time.busy=3.80ms time.idle=32.6µs id=65232218-b913-4d5d-97e2-9a99e461cf68
2024-06-20T16:12:38.450683Z  INFO set_project_active: crates\gitbutler-tauri\src\projects.rs:49: new id=65232218-b913-4d5d-97e2-9a99e461cf68
2024-06-20T16:12:38.451147Z  INFO git_head: crates\gitbutler-tauri\src\commands.rs:68: new project_id=65232218-b913-4d5d-97e2-9a99e461cf68
2024-06-20T16:12:38.452657Z  INFO set_project_active:watch: crates\gitbutler-tauri\src\watcher.rs:102: new id=65232218-b913-4d5d-97e2-9a99e461cf68
2024-06-20T16:12:38.453327Z  INFO fetch_from_remotes: crates\gitbutler-tauri\src\virtual_branches.rs:500: new project_id=65232218-b913-4d5d-97e2-9a99e461cf68 action=Some("auto")
2024-06-20T16:12:38.471831Z ERROR fetch_from_remotes: crates\gitbutler-tauri\src\virtual_branches.rs:500: error=Error(repository path 'S:/web/servers/hyperion/' is not owned by current user; class=Config (7); code=Owner (-36)) project_id=65232218-b913-4d5d-97e2-9a99e461cf68 action=Some("auto")
2024-06-20T16:12:38.471848Z  INFO fetch_from_remotes: crates\gitbutler-tauri\src\virtual_branches.rs:500: close time.busy=18.5ms time.idle=18.8µs project_id=65232218-b913-4d5d-97e2-9a99e461cf68 action=Some("auto")
2024-06-20T16:12:38.472106Z ERROR git_head: crates\gitbutler-tauri\src\commands.rs:68: error=Error(repository path 'S:/web/servers/hyperion/' is not owned by current user; class=Config (7); code=Owner (-36)) project_id=65232218-b913-4d5d-97e2-9a99e461cf68
2024-06-20T16:12:38.472121Z  INFO git_head: crates\gitbutler-tauri\src\commands.rs:68: close time.busy=21.0ms time.idle=20.3µs project_id=65232218-b913-4d5d-97e2-9a99e461cf68
2024-06-20T16:12:38.486244Z  INFO list_projects: crates\gitbutler-tauri\src\projects.rs:40: new
2024-06-20T16:12:38.486474Z  INFO list_projects: crates\gitbutler-tauri\src\projects.rs:40: close time.busy=204µs time.idle=27.4µs
2024-06-20T16:12:38.497099Z  INFO set_project_active:watch:file monitor: crates\gitbutler-watcher\src\file_monitor.rs:119: new id=65232218-b913-4d5d-97e2-9a99e461cf68 project_id=65232218-b913-4d5d-97e2-9a99e461cf68
Byron commented 4 months ago

Thanks for reporting!

I believe the error occours when GitButler tries to open a Git repository using git2, which implements the slightly cursed safe.directory 'directive' that Git introduced a while ago.

This means that once a Git repository isn't owned by the current user (with some added rules on Windows), it won't be opened at all to assure Git doesn't accidentally fall for a 'rigged' repository that is tuned to execute attacker-controlled binaries on the computer that runs Git. Network shares were specifically mentioned as a reason for creating this safeguard.

With that said, you should be able to follow these instructions to allow any repository by specifying its path. Wildcards are also supported, which you could use to see if that works at all - sometimes it can be hard to specify paths correctly so they actually match with what git2 is seeing.

Once GitButler switched to gitoxide, this won't be an issue anymore as it makes sure to not invoke binaries from untrusted repositories and configuration, while allowing to read everything.

Nicolas-Innocent commented 4 months ago

you were indeed correct.

adding the following to my windows c:\users\.gitconfig did indeed solve the issue.

[safe]
    directory = *

cheers