Skip to content

Commit 5ede345

Browse files
bcrdejongcursoragentwpfleger96
authored
fix(desktop): use forward slashes for git credential.helper on Windows (#3023)
## Problem On Windows, Projects **Remote** view shows an empty file tree and Sync/Clone fails with a mangled credential-helper path, for example: ``` C:\Users\<user>\AppData\Local\Buzz\git-credential-nostr.exe get: line 1: C:Users<user>AppDataLocalBuzzgit-credential-nostr.exe: command not found fatal: could not read Username for 'https://<relay>/git/...': terminal prompts disabled ``` Buzz injects an absolute path into `credential.helper` via `Path::display()`. On Windows that yields backslashes. Git for Windows runs credential helpers through MinGW bash, which treats `\` as escapes and destroys the path, so NIP-98 auth never runs and the blobless temp clone behind Remote view fails. macOS/Linux are unaffected (paths already use `/`). This is unrelated to shipping a stub helper - the bundled `git-credential-nostr.exe` is a real binary. User `~/.gitconfig` workarounds also cannot help here because Projects git sets `GIT_CONFIG_GLOBAL=/dev/null` and injects its own helper. Closes #3025 ## Fix Normalize the helper path to forward slashes before writing `GIT_CONFIG_VALUE_*`: - `desktop/src-tauri/src/commands/project_git_exec.rs` (Projects Remote / Sync) - `desktop/src-tauri/src/managed_agents/runtime.rs` (agent spawn git auth) Forward slashes are accepted by Git on every platform; on macOS/Linux the replace is a no-op. No `cfg(windows)`, packaging, or libgit2 changes. ## How to reproduce (before) 1. Install Buzz on Windows with Git for Windows 2. Connect to a relay that has a repository with at least one pushed branch 3. Open **Projects** -> select the repo -> **Remote** 4. Observe empty tree; Sync/Clone shows the mangled-path / `command not found` error above ## Test plan - [x] Unit: `cargo test --manifest-path desktop/src-tauri/Cargo.toml credential_helper_config_value` (formatter covered on all platforms; no-op for Unix-style paths) - [x] Local Windows NSIS build + install of this branch - [x] Projects -> Remote / Sync against a Buzz relay repo succeeds on Windows after the fix --------- Signed-off-by: Bjorn de Jong <[email protected]> Signed-off-by: Will Pfleger <[email protected]> Co-authored-by: Bjorn de Jong <[email protected]> Co-authored-by: Cursor <[email protected]> Co-authored-by: Will Pfleger <[email protected]>
1 parent 5ee7280 commit 5ede345

3 files changed

Lines changed: 30 additions & 6 deletions

File tree

‎desktop/scripts/check-file-sizes.mjs‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,11 @@ const overrides = new Map([
191191
// runtime.rs re-entered the list after the #1968 merge: main's
192192
// definition-authoritative resolver comments grew it to 982, and the BYOH
193193
// typed harness-descriptor resolution in spawn_agent_child landed on top at
194-
// 1020. This PR's session-title env write in spawn_agent_child adds 12.
194+
// 1020. The session-title env write in spawn_agent_child adds 12.
195195
// Queued to shrink with the next runtime split pass (#2974 follow-up).
196-
["src-tauri/src/managed_agents/runtime.rs", 1032],
196+
// +1: #3023 credential-helper slash normalization (MinGW bash treats
197+
// backslashes as escapes).
198+
["src-tauri/src/managed_agents/runtime.rs", 1033],
197199
// applyWorkspace reposDir parameter plus the validateReposDir binding,
198200
// threaded through Tauri invokes for configurable repos_dir, plus the
199201
// harness-persona-sync `harnessOverride` create-input bit — load-bearing

‎desktop/src-tauri/src/commands/project_git_exec.rs‎

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,23 @@ fn configure_git_auth(command: &mut Command, auth: &GitAuthConfig, needs_credent
173173
return apply_git_config(command, &entries);
174174
};
175175
command.env("NOSTR_PRIVATE_KEY", &auth.nsec);
176-
entries.push(("credential.helper", cred_helper.display().to_string()));
176+
entries.push((
177+
"credential.helper",
178+
credential_helper_config_value(cred_helper),
179+
));
177180
entries.push(("credential.useHttpPath", "true".to_string()));
178181
}
179182
apply_git_config(command, &entries);
180183
}
181184

185+
/// Format a path for git `credential.helper`.
186+
///
187+
/// Git for Windows invokes helpers via MinGW bash, which treats `\` as
188+
/// escapes. Forward slashes work on every platform git supports.
189+
fn credential_helper_config_value(path: &std::path::Path) -> String {
190+
path.to_string_lossy().replace('\\', "/")
191+
}
192+
182193
fn apply_git_config(command: &mut Command, entries: &[(&str, String)]) {
183194
command.env("GIT_CONFIG_COUNT", entries.len().to_string());
184195
for (index, (key, value)) in entries.iter().enumerate() {
@@ -316,10 +327,20 @@ fn validate_clone_url_against_relay(clone_url: &str, relay_base: &str) -> Result
316327
#[cfg(test)]
317328
mod tests {
318329
use super::{
319-
clean_branch, clean_target_ref, git_needs_credentials, git_subcommand, validate_clone_url,
320-
validate_clone_url_against_relay,
330+
clean_branch, clean_target_ref, credential_helper_config_value, git_needs_credentials,
331+
git_subcommand, validate_clone_url, validate_clone_url_against_relay,
321332
};
322333

334+
#[test]
335+
fn credential_helper_config_value_uses_forward_slashes() {
336+
let path =
337+
std::path::PathBuf::from(r"C:\Users\x\AppData\Local\Buzz\git-credential-nostr.exe");
338+
assert_eq!(
339+
credential_helper_config_value(&path),
340+
"C:/Users/x/AppData/Local/Buzz/git-credential-nostr.exe",
341+
);
342+
}
343+
323344
#[test]
324345
fn git_subcommand_skips_global_config_options() {
325346
assert_eq!(

‎desktop/src-tauri/src/managed_agents/runtime.rs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,8 @@ pub fn spawn_agent_child(
835835
"GIT_CONFIG_KEY_0",
836836
format!("credential.{relay_http_url}/git.helper"),
837837
);
838-
command.env("GIT_CONFIG_VALUE_0", cred_helper.display().to_string());
838+
let helper = cred_helper.to_string_lossy().replace('\\', "/");
839+
command.env("GIT_CONFIG_VALUE_0", helper);
839840
command.env(
840841
"GIT_CONFIG_KEY_1",
841842
format!("credential.{relay_http_url}/git.useHttpPath"),

0 commit comments

Comments
 (0)