Skip to content

Commit 7a75a73

Browse files
committed
fix: qchat path for deb installations
1 parent 6dcb273 commit 7a75a73

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

crates/q_cli/src/cli/mod.rs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ use std::io::{
2525
Write as _,
2626
stdout,
2727
};
28+
use std::path::PathBuf;
2829
use std::process::ExitCode;
2930

3031
use anstream::{
@@ -57,7 +58,6 @@ use fig_proto::local::UiElement;
5758
use fig_settings::sqlite::database;
5859
use fig_util::directories::home_local_bin;
5960
use fig_util::{
60-
CHAT_BINARY_NAME,
6161
CLI_BINARY_NAME,
6262
PRODUCT_NAME,
6363
directories,
@@ -376,7 +376,7 @@ impl Cli {
376376
}
377377
}
378378

379-
let mut cmd = tokio::process::Command::new(home_local_bin()?.join(CHAT_BINARY_NAME));
379+
let mut cmd = tokio::process::Command::new(qchat_path()?);
380380
cmd.arg(subcmd);
381381
if let Some(args) = args {
382382
cmd.args(args);
@@ -534,6 +534,26 @@ async fn launch_dashboard(help_fallback: bool) -> Result<ExitCode> {
534534
Ok(ExitCode::SUCCESS)
535535
}
536536

537+
#[cfg(target_os = "linux")]
538+
fn qchat_path() -> Result<PathBuf> {
539+
use fig_os_shim::Context;
540+
use fig_util::consts::CHAT_BINARY_NAME;
541+
542+
let ctx = Context::new();
543+
if let Some(path) = ctx.process_info().current_pid().exe() {
544+
// This is required for deb installations.
545+
if path.starts_with("/usr/bin") {
546+
return Ok(PathBuf::from("/usr/bin").join(CHAT_BINARY_NAME));
547+
}
548+
}
549+
Ok(home_local_bin()?.join(CHAT_BINARY_NAME))
550+
}
551+
552+
#[cfg(not(target_os = "linux"))]
553+
fn qchat_path() -> Result<PathBuf> {
554+
Ok(home_local_bin()?.join(fig_util::consts::CHAT_BINARY_NAME))
555+
}
556+
537557
#[cfg(test)]
538558
mod test {
539559
use super::*;

0 commit comments

Comments
 (0)