fix(make): harden dx-cli preflight against wrong-binary collisions #82
No reviewers
Labels
No labels
prio_critical
prio_low
type_bug
type_contact
type_issue
type_lead
type_question
type_story
type_task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lhumina_code/hero_os!82
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/dx-preflight-wrong-binary"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Fixes
make build-wasm(and related targets) so they no longer fail cryptically when an unrelateddxbinary is earlier onPATHthan Dioxus CLI — and auto-installs Dioxus CLI on first build so fresh machines bootstrap transparently.Closes #81.
The original bug
command -v dxin_check-dxis satisfied by any executable nameddx. Common collisions seen in the wild:/usr/bin/dx→ OpenDX (data-visualization tool) on Debian/Ubuntu/opt/homebrew/bin/dx→ Deno'sdeno xshim on macOS with Homebrewdxin a system-managed directoryWith the wrong
dxfirst on PATH, the preflight "passes", thendx buildruns against e.g. OpenDX and produces:Unreadable, and nothing points at PATH shadowing as the cause.
The fix
Pin
$(DX)to~/.cargo/bin/dxunconditionally. No PATH lookup, no ambiguity. That's wherecargo install dioxus-cliputs the binary, which is the one path of true.Auto-install on first build.
_check-dxnow bootstraps Dioxus CLI instead of erroring:$(DX)missing →cargo install dioxus-cli --locked$(DX)exists but is not Dioxus (rare) →cargo install ... --forcecargoitself missing → fail with a pointer to https://rustup.rsPost-install validation (
$(DX) --version | grep -qi dioxus) remains as defense-in-depth.All rule recipes that previously called
dxnow call$(DX):web,dev,desktop,build,build-wasm.Behaviour matrix
make build-wasm(3-10 min), then proceeds~/.cargo/bin/dxdxon PATH, no Dioxus~/.cargo/bin/dx, uses it~/.cargo/bin/dxcargo install --forcereplaces itcargoinstalled at allCommits
a2acc0a fix(make): harden dx-cli preflight against wrong-binary collisions— the original error-clearly approach.31336bb fix(make): auto-install Dioxus CLI when missing or wrong— upgraded to auto-install.Happy to squash into one on merge.
Verified
On macOS dev box with Dioxus CLI already installed at
~/.cargo/bin/dx:Preflight is a no-op when Dioxus is already present. Builds proceed against the cargo-installed binary directly.
On Debian dev box with OpenDX at
/usr/bin/dxand no Dioxus CLI, the original (commit 1) behaviour was confirmed correct — clear error instead of cryptic failure. Commit 2 extends that to auto-install instead of error.Notes
--lockedincargo installpins transitive dep versions to what dioxus-cli's ownCargo.lockspecifies — reproducible installs.make build-wasmdoesn't appear to hang.Makefile, no other files touched.`command -v dx` in _check-dx is satisfied by any executable named `dx` on PATH, including: - /usr/bin/dx → OpenDX (data-visualization) on Debian/Ubuntu - /opt/homebrew/bin/dx → Deno's `deno x` shim on macOS with Homebrew - any other name-collision The preflight then "succeeds" and build/serve targets invoke the wrong `dx`, producing cryptic errors like: /usr/bin/dx : unrecognized parameter: [1] make: *** [Makefile:110: build-wasm] Error 1 Two changes: 1. Resolve `dx` deterministically. Prefer ~/.cargo/bin/dx (where `cargo install dioxus-cli` installs it) before falling back to whatever's on PATH. Assigned to `DX`. 2. Validate after resolution. Run `$(DX) --version` and grep for "dioxus" in the output. If absent, the found binary is not Dioxus CLI; print the resolved path, the install command, and the PATH-order hint, then exit. All targets that called `dx` now call `$(DX)`: web, dev, desktop, build, build-wasm. Behaviour unchanged on any machine where Dioxus CLI is the only `dx` on PATH, or where ~/.cargo/bin/dx is Dioxus CLI.