@@ -25,6 +25,7 @@ use std::io::{
25
25
Write as _,
26
26
stdout,
27
27
} ;
28
+ use std:: path:: PathBuf ;
28
29
use std:: process:: ExitCode ;
29
30
30
31
use anstream:: {
@@ -57,15 +58,13 @@ use fig_proto::local::UiElement;
57
58
use fig_settings:: sqlite:: database;
58
59
use fig_util:: directories:: home_local_bin;
59
60
use fig_util:: {
60
- CHAT_BINARY_NAME ,
61
61
CLI_BINARY_NAME ,
62
62
PRODUCT_NAME ,
63
63
directories,
64
64
manifest,
65
65
system_info,
66
66
} ;
67
67
use internal:: InternalSubcommand ;
68
- use macos_utils:: bundle:: get_bundle_path_for_executable;
69
68
use serde:: Serialize ;
70
69
use tokio:: signal:: ctrl_c;
71
70
use tracing:: {
@@ -376,14 +375,6 @@ impl Cli {
376
375
}
377
376
378
377
pub async fn execute_chat ( subcmd : & str , args : Option < Vec < String > > , enforce_login : bool ) -> Result < ExitCode > {
379
- cfg_if:: cfg_if! {
380
- if #[ cfg( target_os = "macos" ) ] {
381
- let path = get_bundle_path_for_executable( CHAT_BINARY_NAME ) . unwrap_or( home_local_bin( ) ?. join( CHAT_BINARY_NAME ) ) ;
382
- } else {
383
- let path = home_local_bin( ) ?. join( CHAT_BINARY_NAME ) ;
384
- }
385
- }
386
-
387
378
if enforce_login {
388
379
assert_logged_in ( ) . await ?;
389
380
}
@@ -399,7 +390,7 @@ impl Cli {
399
390
}
400
391
}
401
392
402
- let mut cmd = tokio:: process:: Command :: new ( & path ) ;
393
+ let mut cmd = tokio:: process:: Command :: new ( qchat_path ( ) ? ) ;
403
394
cmd. arg ( subcmd) ;
404
395
if let Some ( args) = args {
405
396
cmd. args ( args) ;
@@ -557,6 +548,28 @@ async fn launch_dashboard(help_fallback: bool) -> Result<ExitCode> {
557
548
Ok ( ExitCode :: SUCCESS )
558
549
}
559
550
551
+ #[ cfg( target_os = "linux" ) ]
552
+ fn qchat_path ( ) -> Result < PathBuf > {
553
+ use fig_os_shim:: Context ;
554
+ use fig_util:: consts:: CHAT_BINARY_NAME ;
555
+
556
+ let ctx = Context :: new ( ) ;
557
+ if let Some ( path) = ctx. process_info ( ) . current_pid ( ) . exe ( ) {
558
+ // This is required for deb installations.
559
+ if path. starts_with ( "/usr/bin" ) {
560
+ return Ok ( PathBuf :: from ( "/usr/bin" ) . join ( CHAT_BINARY_NAME ) ) ;
561
+ }
562
+ }
563
+ Ok ( home_local_bin ( ) ?. join ( CHAT_BINARY_NAME ) )
564
+ }
565
+
566
+ #[ cfg( target_os = "macos" ) ]
567
+ fn qchat_path ( ) -> Result < PathBuf > {
568
+ use macos_utils:: bundle:: get_bundle_path_for_executable;
569
+
570
+ Ok ( get_bundle_path_for_executable ( CHAT_BINARY_NAME ) . unwrap_or ( home_local_bin ( ) ?. join ( CHAT_BINARY_NAME ) ) )
571
+ }
572
+
560
573
#[ cfg( test) ]
561
574
mod test {
562
575
use super :: * ;
0 commit comments