From 72dcb66a89c8ec2ea6c6f8ce17e88e48afe70c0b Mon Sep 17 00:00:00 2001 From: Brandon Kiser Date: Wed, 14 May 2025 18:06:53 -0700 Subject: [PATCH 1/2] fix: qchat path for deb installations --- crates/q_cli/src/cli/mod.rs | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/crates/q_cli/src/cli/mod.rs b/crates/q_cli/src/cli/mod.rs index 51bbf3831..3ed16cacc 100644 --- a/crates/q_cli/src/cli/mod.rs +++ b/crates/q_cli/src/cli/mod.rs @@ -25,6 +25,7 @@ use std::io::{ Write as _, stdout, }; +use std::path::PathBuf; use std::process::ExitCode; use anstream::{ @@ -57,7 +58,6 @@ use fig_proto::local::UiElement; use fig_settings::sqlite::database; use fig_util::directories::home_local_bin; use fig_util::{ - CHAT_BINARY_NAME, CLI_BINARY_NAME, PRODUCT_NAME, directories, @@ -65,7 +65,6 @@ use fig_util::{ system_info, }; use internal::InternalSubcommand; -use macos_utils::bundle::get_bundle_path_for_executable; use serde::Serialize; use tokio::signal::ctrl_c; use tracing::{ @@ -376,14 +375,6 @@ impl Cli { } pub async fn execute_chat(subcmd: &str, args: Option>, enforce_login: bool) -> Result { - cfg_if::cfg_if! { - if #[cfg(target_os = "macos")] { - let path = get_bundle_path_for_executable(CHAT_BINARY_NAME).unwrap_or(home_local_bin()?.join(CHAT_BINARY_NAME)); - } else { - let path = home_local_bin()?.join(CHAT_BINARY_NAME); - } - } - if enforce_login { assert_logged_in().await?; } @@ -399,7 +390,7 @@ impl Cli { } } - let mut cmd = tokio::process::Command::new(&path); + let mut cmd = tokio::process::Command::new(qchat_path()?); cmd.arg(subcmd); if let Some(args) = args { cmd.args(args); @@ -557,6 +548,28 @@ async fn launch_dashboard(help_fallback: bool) -> Result { Ok(ExitCode::SUCCESS) } +#[cfg(target_os = "linux")] +fn qchat_path() -> Result { + use fig_os_shim::Context; + use fig_util::consts::CHAT_BINARY_NAME; + + let ctx = Context::new(); + if let Some(path) = ctx.process_info().current_pid().exe() { + // This is required for deb installations. + if path.starts_with("/usr/bin") { + return Ok(PathBuf::from("/usr/bin").join(CHAT_BINARY_NAME)); + } + } + Ok(home_local_bin()?.join(CHAT_BINARY_NAME)) +} + +#[cfg(target_os = "macos")] +fn qchat_path() -> Result { + use macos_utils::bundle::get_bundle_path_for_executable; + + Ok(get_bundle_path_for_executable(CHAT_BINARY_NAME).unwrap_or(home_local_bin()?.join(CHAT_BINARY_NAME))) +} + #[cfg(test)] mod test { use super::*; From 569adea965fd955f5d7f5aa94d60f93d0f4c0969 Mon Sep 17 00:00:00 2001 From: Brandon Kiser Date: Wed, 14 May 2025 18:20:08 -0700 Subject: [PATCH 2/2] fix macos --- crates/q_cli/src/cli/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/q_cli/src/cli/mod.rs b/crates/q_cli/src/cli/mod.rs index 3ed16cacc..f31d76534 100644 --- a/crates/q_cli/src/cli/mod.rs +++ b/crates/q_cli/src/cli/mod.rs @@ -565,6 +565,7 @@ fn qchat_path() -> Result { #[cfg(target_os = "macos")] fn qchat_path() -> Result { + use fig_util::consts::CHAT_BINARY_NAME; use macos_utils::bundle::get_bundle_path_for_executable; Ok(get_bundle_path_for_executable(CHAT_BINARY_NAME).unwrap_or(home_local_bin()?.join(CHAT_BINARY_NAME)))