Skip to content

Commit b1fb45b

Browse files
committed
When running pnpm tauri dev, make sure askpass is checked in the right directory
1 parent bbde3ab commit b1fb45b

File tree

1 file changed

+46
-13
lines changed

1 file changed

+46
-13
lines changed

crates/gitbutler-git/src/repository.rs

Lines changed: 46 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -95,23 +95,56 @@ where
9595
#[cfg(feature = "test-askpass-path")]
9696
let current_exe = current_exe.parent().unwrap();
9797

98-
let askpath_path = current_exe
99-
.with_file_name({
100-
#[cfg(unix)]
101-
{
102-
"gitbutler-git-askpass"
103-
}
104-
#[cfg(windows)]
98+
let mut bin_dir = current_exe.parent().unwrap().to_path_buf();
99+
100+
let askpass_name = {
101+
#[cfg(unix)]
102+
{
103+
"gitbutler-git-askpass"
104+
}
105+
#[cfg(windows)]
106+
{
107+
"gitbutler-git-askpass.exe"
108+
}
109+
};
110+
111+
// Only in dev mode, check that we're in the right dir.
112+
// When running from tauri CARGO_TARGET_DIR=target/tauri, the tauri binary is in target/tauri/debug
113+
// but auxiliary binaries are in target/debug. Detect this and use the correct directory.
114+
#[cfg(debug_assertions)]
115+
{
116+
let candidate_dirs = [
117+
bin_dir.to_path_buf(),
118+
bin_dir
119+
.parent()
120+
.and_then(|p| p.parent())
121+
.map(|p| p.join("debug").to_path_buf())
122+
.unwrap_or_else(|| bin_dir.to_path_buf()),
123+
];
124+
125+
for candidate_dir in candidate_dirs.iter() {
126+
let candidate_path = candidate_dir.join(askpass_name);
127+
if executor
128+
.stat(&candidate_path.to_string_lossy().into_owned())
129+
.await
130+
.is_ok()
105131
{
106-
"gitbutler-git-askpass.exe"
132+
bin_dir = candidate_dir.clone();
133+
break;
107134
}
108-
})
109-
.to_string_lossy()
110-
.into_owned();
135+
}
136+
tracing::info!(
137+
"Using askpass binary directory: {:?} after checking candidates: {:?}",
138+
bin_dir,
139+
candidate_dirs
140+
);
141+
}
142+
143+
let askpath_path = bin_dir.join(askpass_name).to_string_lossy().into_owned();
111144

112145
#[cfg(unix)]
113-
let setsid_path = current_exe
114-
.with_file_name("gitbutler-git-setsid")
146+
let setsid_path = bin_dir
147+
.join("gitbutler-git-setsid")
115148
.to_string_lossy()
116149
.into_owned();
117150

0 commit comments

Comments
 (0)