Skip to content

fix(cli): copy external_bin sidecars on Windows by appending .exe#5583

Open
Booyaka101 wants to merge 1 commit into
DioxusLabs:mainfrom
Booyaka101:fix/5578-external-bin-windows-exe
Open

fix(cli): copy external_bin sidecars on Windows by appending .exe#5583
Booyaka101 wants to merge 1 commit into
DioxusLabs:mainfrom
Booyaka101:fix/5578-external-bin-windows-exe

Conversation

@Booyaka101
Copy link
Copy Markdown

Closes #5578.

dx bundle was silently dropping external_bin sidecars on Windows. copy_external_binaries in packages/cli/src/bundler/mod.rs constructed the staging path as {bin}-{target} without .exe, so src.exists() was always false for the file users actually produce (my_backend-x86_64-pc-windows-msvc.exe). The binary was missing from _staging and no warning was emitted.

Fix

Extract the path construction into a small external_bin_src_path helper that appends .exe when the target triple contains \"windows\" — matching the convention already used at bundler/windows.rs:406 for the main binary. The replace-based dest_name derivation already preserves the extension correctly because file_name() returns it as-is.

The check is target-only (not cfg!(target_os = \"windows\")-gated like the main-binary path does) because the sidecar naming convention is determined by the target platform, not the build host — staging foo-x86_64-unknown-linux-gnu on a Windows host should not look for .exe.

Tests

Three regression tests added to bundler::tests:

  1. external_bin_src_path_appends_exe_on_windows_targets — path appends .exe on every Rust Windows target triple (msvc, gnu, x86_64, aarch64).
  2. external_bin_src_path_no_extension_on_non_windows_targets — path is unchanged on Linux, macOS, wasm32 targets (no false positives).
  3. external_bin_src_path_finds_staged_windows_binary — full end-to-end against a real filesystem: stage a real .exe in a tempdir, resolve through the helper, run the exact file_name().replace(...) + std::fs::copy(...) sequence from copy_external_binaries, assert the destination ends up as my_backend.exe with the original bytes.

Verified locally on Windows: cargo test bundler::tests:: → 4/4 pass (3 new + the pre-existing zip_dir_preserves_layout_and_permissions). cargo clippy --bin dx --tests -- -D warnings and cargo fmt --check both clean on the touched code.

`dx bundle` was silently dropping `external_bin` sidecars on Windows.
`copy_external_binaries` constructed the staging path as
`{bin}-{target}` without the `.exe` extension, so `src.exists()` was
always false for the file users actually produce
(`my_backend-x86_64-pc-windows-msvc.exe`). The binary was missing from
`_staging` and no warning was emitted.

Extract the path construction into a small `external_bin_src_path`
helper that appends `.exe` when the target triple contains `"windows"`
(matching the convention already used at `bundler/windows.rs:406` for
the main binary). The replace-based `dest_name` derivation already
preserves the extension correctly because `file_name()` returns it
as-is.

Includes three regression tests:
- path appends `.exe` on every Windows target triple
- path is unchanged on Linux, macOS, wasm32 targets
- end-to-end: stage a real `.exe` in a tempdir, resolve through the
  helper, run the exact `file_name().replace(...) + std::fs::copy(...)`
  sequence from `copy_external_binaries`, assert the destination ends
  up as `my_backend.exe` with the original bytes.

Closes DioxusLabs#5578.
@Booyaka101 Booyaka101 requested a review from a team as a code owner May 24, 2026 05:34
@Booyaka101
Copy link
Copy Markdown
Author

The failing check is "Check | Minimum dependency versions" and it errors out inside rhai 1.24.0 (packages/string_more.rs:21 -> could not find rhai in the list of imported crates), pulled in transitively through cargo-generate = "=0.23.10" in packages/cli/Cargo.toml. Nothing this PR touches is on that path.

Same check is failing on #5587 (also opened 2026-05-26) for the same reason. Rhai 1.25.0 was published 2026-05-24, and from that point on -Zdirect-minimal-versions resolves a combination of rhai's own transitive minimums that don't actually compile (looks like a too-loose lower bound on rhai_codegen inside rhai 1.24.0's manifest, so the codegen crate the resolver picks no longer matches what rhai's source expects).

The pre-existing successful run on this branch (2026-05-26T15:53Z attempt 1 of run 26353043246) hit it after the 1.25.0 publication window. Not something I can fix from inside this diff. Options on your side would be bumping the cargo-generate pin to a release that requires a fixed rhai, or letting min-deps continue-on-error until rhai 1.24.0 gets yanked. Happy to follow whatever you'd prefer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant