DioxusLabs / DioxusLabs/dioxus

dx bundle silently ignores external_bin on Windows due to missing .exe extension check

Open
#5,578 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Rust
Stars
39.1k
Forks
1.9k
Avg merge
4d 10h
Merged PRs (30d)
4

Description

**Problem**

When bundling a desktop application with additional binaries (external_bin / sidecars), dx bundle silently skips copying these binaries on Windows. This happens because the path resolution logic in the CLI performs a naive string concatenation to find the staged binary, forgetting that Windows binaries require a .exe file extension to be found by std::fs::metadata / Path::exists.

**Where the bug occurs:**

In `packages/cli/src/bundle/mod.rs` (around the copy_external_binaries function):

```rust
pub(crate) fn copy_external_binaries(&self, dest: &Path) -> Result> {
let mut paths = Vec::new();
if let Some(bins) = &self.build.config.bundle.external_bin {
let target = self.target();
for bin in bins {
// BUG: This constructs a path without ".exe" on Windows
let src = PathBuf::from(format!("{bin}-{target}"));
if src.exists() {
let dest_name = src
.file_name()
.unwrap()
.to_string_lossy()
.replace(&format!("-{target}"), "");
let dest_path = dest.join(dest_name);
std::fs::copy(&src, &dest_path)?;
paths.push(dest_path);
}
}
}
Ok(paths)
}
```

**Steps To Reproduce**

Steps to reproduce the behavior:

1. Add an external binary to Dioxus.toml:

```toml
[bundle]
external_bin = ["staging/my_backend"]
```

2. Stage the corresponding Windows binary in the workspace directory as required by the naming convention:
staging/my_backend-x86_64-pc-windows-msvc.exe
3. Run dx bundle --release --verbose --package-types nsis on Windows.
4. Check the verbose log or the final _staging directory. The binary is missing, and no warning/error is emitted because `src.exists()` evaluated to `false` (looking for `my_backend-x86_64-pc-windows-msvc` without `.exe`).

**Expected behavior**

The CLI should successfully locate the binary on Windows even if it has a .exe extension, and strip the target suffix correctly while preserving the .exe extension for the target directory deployment.

**Environment:**

* **Dioxus CLI Version:** 0.7.9
* **OS:** Windows (x86_64-pc-windows-msvc)
* **Rust Version:** 1.95+

**Suggested Fix**
Account for the platform-specific executable extension when constructing the path and stripping the target triple string, for example:

```rust
let is_windows = target.contains("windows");
let ext = if is_windows { ".exe" } else { "" };

// Append extension to search query if on Windows
let src = PathBuf::from(format!("{bin}-{target}{ext}"));
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.