Merge pull request #5530 from shmutalov/feat/old-mac-support

feat: old mac support
This commit is contained in:
Louis 2025-08-05 11:08:14 +07:00 committed by GitHub
commit 80707c42e8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 3 deletions

View File

@ -10,7 +10,11 @@ use tokio::{
time::{sleep, timeout},
};
use super::{cmd::get_jan_data_folder_path, state::AppState};
use super::{
cmd::get_jan_data_folder_path,
state::AppState,
utils::can_override_npx,
};
const DEFAULT_MCP_CONFIG: &str = r#"{
"mcpServers": {
@ -513,7 +517,7 @@ async fn schedule_mcp_start_task<R: Runtime>(
let mut cmd = Command::new(command.clone());
if command == "npx" {
if command == "npx" && can_override_npx() {
let mut cache_dir = app_path.clone();
cache_dir.push(".npx");
let bun_x_path = format!("{}/bun", bin_path.display());

View File

@ -103,6 +103,21 @@ pub fn normalize_path(path: &Path) -> PathBuf {
ret
}
pub fn can_override_npx() -> bool {
// we need to check the CPU for the AVX2 instruction support if we are running under the MacOS
// with Intel CPU. We can override `npx` command with `bun` only if CPU is
// supporting AVX2, otherwise we need to use default `npx` binary
#[cfg(all(target_os = "macos", any(target_arch = "x86", target_arch = "x86_64")))]
{
if !is_x86_feature_detected!("avx2") {
log::warn!("Your CPU doesn't support AVX2 instruction, default npx binary will be used");
return false; // we cannot override npx with bun binary
}
}
true // by default, we can override npx with bun binary
}
#[tauri::command]
pub fn write_yaml(
app: tauri::AppHandle,