Files
moho/scripts/build-daemon.sh
T
SalastilandClaude Opus 5 03d821cd52 Find a cargo that works, rather than one called cargo
npm run deploy stopped building the daemon, with "rustup could not
choose a version of cargo to run" - which reads like rust is missing and
is not.

rustup installs a shim, and the shim finds the real toolchain through
CARGO_HOME and RUSTUP_HOME. On the XDG layout those point under
~/.local/share rather than ~/.cargo, so they are named by environment
variables a login shell sets and an npm script never sees. The shim then
has nowhere to look.

The distribution's own /usr/bin/cargo does run, which makes it look like
the answer, and for a native build it is. It is also the wrong one: it
carries no cross-compilation targets, so a Windows build through it
fails with "can't find crate for `core`" - which in turn reads like a
broken checkout. Each wrong answer points at the other, which is why
this has been worked around by hand all week instead of fixed.

So the XDG locations are filled in when nothing else has, rustup's shim
is preferred because it is the toolchain carrying the targets, and every
candidate is asked `--version` rather than assumed - that question being
the only thing that tells a working toolchain from a shim that cannot
find one. The Linux build goes through the same script as the Windows
one now, since it had the same problem and no reason to solve it
differently.

Both were verified through npm rather than from a shell that already had
the right environment, which is the only way this bug is visible at all.

Co-Authored-By: Claude Opus 5 <[email protected]>
2026-08-31 22:19:41 -04:00

13 lines
388 B
Bash
Executable File

#!/usr/bin/env sh
# Builds the daemon for this machine, with a cargo that works.
#
# See find-cargo.sh for why "run cargo" is not as simple as it sounds when the
# caller is an npm script.
set -eu
SRC_DIR="$(cd "$(dirname "$0")/.." && pwd)"
. "$SRC_DIR/scripts/find-cargo.sh"
echo "building the daemon with $CARGO"
"$CARGO" build --release --manifest-path "$SRC_DIR/nobilis/Cargo.toml"