[nu-demo] hero_os Makefile ignores CARGO_TARGET_DIR and hardcodes ~/.cargo/bin/dx #131

Closed
opened 2026-04-23 23:15:05 +00:00 by mik-tf · 1 comment
Owner

Symptom

  1. make install-assets-release (and the debug equivalent) rsync fails silently — WASM assets never reach the install dir, the shell renders with missing JS/WASM.
  2. make triggers cargo install dioxus-cli even though a working dx binary exists at ~/hero/bin/dx.

Root cause

hero_os/Makefile hardcodes:

WASM_DEBUG_OUTPUT := target/dx/hero_os_app/debug/web/public
WASM_RELEASE_OUTPUT := target/dx/hero_os_app/release/web/public

assuming cargo's default ./target/. When CARGO_TARGET_DIR=~/hero/build/cargo is set (standard hero env), dx build writes to $CARGO_TARGET_DIR/dx/..., so the Makefile rsync looks in the wrong path and silently fails to find anything.

Also, _check-dx only probes ~/.cargo/bin/dx and re-installs via cargo install dioxus-cli if absent. It doesn't consider ~/hero/bin/dx, which is where the hero env places it.

Demo workaround (applied 2026-04-23)

  • Manual rsync from the actual $CARGO_TARGET_DIR/dx/hero_os_app/{debug,release}/web/public/ path into the install dir.
  • Symlinked: ln -sfn ~/hero/bin/dx ~/.cargo/bin/dx so _check-dx is satisfied without a reinstall.

Proper fix

(a) Makefile should use $(or $(CARGO_TARGET_DIR),target)/dx/hero_os_app/<profile>/web/public for both debug and release WASM output paths. Apply to both install-assets-debug and install-assets-release rules (same bug in both — folds in the duplicate that would have been #19).
(b) _check-dx should probe both ~/.cargo/bin/dx and ~/hero/bin/dx (and $PATH's dx) before attempting cargo install.

Filed 2026-04-23 nu-shell demo bring-up. Signed-off-by: mik-tf

## Symptom 1. `make install-assets-release` (and the debug equivalent) rsync fails silently — WASM assets never reach the install dir, the shell renders with missing JS/WASM. 2. `make` triggers `cargo install dioxus-cli` even though a working `dx` binary exists at `~/hero/bin/dx`. ## Root cause `hero_os/Makefile` hardcodes: ``` WASM_DEBUG_OUTPUT := target/dx/hero_os_app/debug/web/public WASM_RELEASE_OUTPUT := target/dx/hero_os_app/release/web/public ``` assuming cargo's default `./target/`. When `CARGO_TARGET_DIR=~/hero/build/cargo` is set (standard hero env), `dx build` writes to `$CARGO_TARGET_DIR/dx/...`, so the Makefile rsync looks in the wrong path and silently fails to find anything. Also, `_check-dx` only probes `~/.cargo/bin/dx` and re-installs via `cargo install dioxus-cli` if absent. It doesn't consider `~/hero/bin/dx`, which is where the hero env places it. ## Demo workaround (applied 2026-04-23) - Manual rsync from the actual `$CARGO_TARGET_DIR/dx/hero_os_app/{debug,release}/web/public/` path into the install dir. - Symlinked: `ln -sfn ~/hero/bin/dx ~/.cargo/bin/dx` so `_check-dx` is satisfied without a reinstall. ## Proper fix (a) Makefile should use `$(or $(CARGO_TARGET_DIR),target)/dx/hero_os_app/<profile>/web/public` for both debug and release WASM output paths. Apply to both `install-assets-debug` and `install-assets-release` rules (same bug in both — folds in the duplicate that would have been #19). (b) `_check-dx` should probe both `~/.cargo/bin/dx` and `~/hero/bin/dx` (and `$PATH`'s `dx`) before attempting `cargo install`. Filed 2026-04-23 nu-shell demo bring-up. Signed-off-by: mik-tf
Author
Owner

Fixed in hero_os commit 03477c4 on development.

Two coupled fixes in Makefile:

1. CARGO_TARGET_DIR — fixes silent rsync failure:

+# Cargo writes WASM artifacts under $(CARGO_TARGET_DIR)/dx/... when the env
+# var is set (standard hero env: ~/hero/build/cargo). Default to ./target
+# when unset so a vanilla cargo build still works.
+CARGO_TARGET_DIR ?= target
-WASM_DEBUG_OUTPUT := target/dx/hero_os_app/debug/web/public
-WASM_RELEASE_OUTPUT := target/dx/hero_os_app/release/web/public
+WASM_DEBUG_OUTPUT := $(CARGO_TARGET_DIR)/dx/hero_os_app/debug/web/public
+WASM_RELEASE_OUTPUT := $(CARGO_TARGET_DIR)/dx/hero_os_app/release/web/public

?= only sets the variable if not already defined, so an env-exported value (e.g. CARGO_TARGET_DIR=~/hero/build/cargo) takes precedence and an unset value falls back to ./target — vanilla cargo behavior preserved. The cosmetic "Done: target/..." echo lines (L138, L143) were also updated to use the variable.

2. DX binary lookup — fixes redundant 3-10 min reinstall on TF Grid / nu-server deploys:

-DX := $(HOME)/.cargo/bin/dx
+DX := $(if $(wildcard $(HOME)/hero/bin/dx),$(HOME)/hero/bin/dx,$(HOME)/.cargo/bin/dx)

hero_skills installs Dioxus CLI to ~/hero/bin/dx. The previous unconditional DX := ~/.cargo/bin/dx ignored that and re-ran cargo install dioxus-cli if the cargo path was empty. Now the Makefile prefers ~/hero/bin/dx when present, falls through to ~/.cargo/bin/dx otherwise. Pinned-path discipline (no PATH lookup) is preserved — OS-bundled dx shims (OpenDX on Debian, Deno on macOS) still cannot shadow it.

Verification (make -n -p):

Scenario WASM_RELEASE_OUTPUT
default target/dx/hero_os_app/release/web/public
CARGO_TARGET_DIR=/tmp/foo /tmp/foo/dx/hero_os_app/release/web/public

DX falls to ~/.cargo/bin/dx when ~/hero/bin/dx is absent (verified locally on a dev box without hero_skills installed).

Meta-tracker: home#193.

Signed-off-by: mik-tf

Fixed in hero_os commit `03477c4` on `development`. Two coupled fixes in `Makefile`: **1. `CARGO_TARGET_DIR` — fixes silent rsync failure:** ```diff +# Cargo writes WASM artifacts under $(CARGO_TARGET_DIR)/dx/... when the env +# var is set (standard hero env: ~/hero/build/cargo). Default to ./target +# when unset so a vanilla cargo build still works. +CARGO_TARGET_DIR ?= target -WASM_DEBUG_OUTPUT := target/dx/hero_os_app/debug/web/public -WASM_RELEASE_OUTPUT := target/dx/hero_os_app/release/web/public +WASM_DEBUG_OUTPUT := $(CARGO_TARGET_DIR)/dx/hero_os_app/debug/web/public +WASM_RELEASE_OUTPUT := $(CARGO_TARGET_DIR)/dx/hero_os_app/release/web/public ``` `?=` only sets the variable if not already defined, so an env-exported value (e.g. `CARGO_TARGET_DIR=~/hero/build/cargo`) takes precedence and an unset value falls back to `./target` — vanilla cargo behavior preserved. The cosmetic `"Done: target/..."` echo lines (L138, L143) were also updated to use the variable. **2. `DX` binary lookup — fixes redundant 3-10 min reinstall on TF Grid / nu-server deploys:** ```diff -DX := $(HOME)/.cargo/bin/dx +DX := $(if $(wildcard $(HOME)/hero/bin/dx),$(HOME)/hero/bin/dx,$(HOME)/.cargo/bin/dx) ``` `hero_skills` installs Dioxus CLI to `~/hero/bin/dx`. The previous unconditional `DX := ~/.cargo/bin/dx` ignored that and re-ran `cargo install dioxus-cli` if the cargo path was empty. Now the Makefile prefers `~/hero/bin/dx` when present, falls through to `~/.cargo/bin/dx` otherwise. Pinned-path discipline (no PATH lookup) is preserved — OS-bundled `dx` shims (OpenDX on Debian, Deno on macOS) still cannot shadow it. **Verification** (`make -n -p`): | Scenario | `WASM_RELEASE_OUTPUT` | |----------|-----------------------| | default | `target/dx/hero_os_app/release/web/public` | | `CARGO_TARGET_DIR=/tmp/foo` | `/tmp/foo/dx/hero_os_app/release/web/public` | DX falls to `~/.cargo/bin/dx` when `~/hero/bin/dx` is absent (verified locally on a dev box without hero_skills installed). Meta-tracker: home#193. Signed-off-by: mik-tf
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lhumina_code/home#131
No description provided.