Skip to content

Commit 98dae36

Browse files
committed
fix(setup): make CLI install cross-platform for Windows GUI build
step_install_cli used std::os::unix::fs::symlink unconditionally, breaking the Windows Tauri build. Gate it: symlink on Unix, copy on Windows (no user symlinks without elevation). Add a Windows variant of cli_symlink_path targeting ~/.local/bin/lumen.exe.
1 parent 3b84696 commit 98dae36

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

lumenator/src-tauri/src/setup.rs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -738,9 +738,16 @@ fn step_install_cli() -> SetupStep {
738738

739739
let _ = std::fs::remove_file(&target);
740740

741-
match std::os::unix::fs::symlink(&lumen_bin, &target) {
741+
// Unix: symlink into a bin dir on PATH. Windows lacks user symlinks without
742+
// elevation/developer-mode, so copy the binary into place instead.
743+
#[cfg(unix)]
744+
let result = std::os::unix::fs::symlink(&lumen_bin, &target);
745+
#[cfg(windows)]
746+
let result = std::fs::copy(&lumen_bin, &target).map(|_| ());
747+
748+
match result {
742749
Ok(_) => SetupStep::ok("cli", "Install CLI", &format!("{}", target.display())),
743-
Err(e) => SetupStep::err("cli", "Install CLI", &format!("symlink: {e}")),
750+
Err(e) => SetupStep::err("cli", "Install CLI", &format!("install: {e}")),
744751
}
745752
}
746753

@@ -764,6 +771,7 @@ fn step_remove_cli_symlink() -> SetupStep {
764771
}
765772
}
766773

774+
#[cfg(unix)]
767775
fn cli_symlink_path() -> PathBuf {
768776
if std::path::Path::new("/usr/local/bin").is_dir() {
769777
PathBuf::from("/usr/local/bin/lumen")
@@ -774,6 +782,13 @@ fn cli_symlink_path() -> PathBuf {
774782
}
775783
}
776784

785+
#[cfg(windows)]
786+
fn cli_symlink_path() -> PathBuf {
787+
dirs::home_dir()
788+
.map(|h| h.join(".local").join("bin").join("lumen.exe"))
789+
.unwrap_or_else(|| PathBuf::from("lumen.exe"))
790+
}
791+
777792
fn remove_lumen_hooks(root: &mut serde_json::Value) {
778793
for phase in &["PreToolUse", "PostToolUse"] {
779794
if let Some(arr) = root["hooks"][phase].as_array_mut() {

0 commit comments

Comments
 (0)