fix(build): remove SODIUM_USE_PKG_CONFIG from .cargo/config.toml [env] block #114

Merged
sarman merged 1 commits from fix/cargo-config-sodium into beta 2026-06-18 02:24:59 +00:00
Owner

Root cause (finally found)

src-tauri/.cargo/config.toml had SODIUM_USE_PKG_CONFIG = "0" in its [env] block. Cargo injects [env] entries directly into each build script's environment at exec time — completely invisible to shell unset or env -u, which only operate on the parent process environment.

The value "0" still makes env::var("SODIUM_USE_PKG_CONFIG").is_ok() return true (it checks presence, not value). Combined with SODIUM_LIB_DIR set in the workflow, the libsodium-sys-stable build script always hit the incompatibility panic.

This is why every workflow-level fix (unset, env -u, different env var approaches) had zero effect — the variable was being re-injected by Cargo itself after exec.

Fix

Remove SODIUM_USE_PKG_CONFIG = "0" from the [env] block in src-tauri/.cargo/config.toml. The original comment claiming it "avoids memset_explicit on Windows" was incorrect — that variable controls detection strategy, not link behaviour. The actual Windows sodium handling is via SODIUM_LIB_DIR in the workflow.

SODIUM_STATIC = "1" is retained as it controls static linking (correct for distribution).

## Root cause (finally found) `src-tauri/.cargo/config.toml` had `SODIUM_USE_PKG_CONFIG = "0"` in its `[env]` block. Cargo injects `[env]` entries directly into each build script's environment at exec time — **completely invisible to shell `unset` or `env -u`**, which only operate on the parent process environment. The value `"0"` still makes `env::var("SODIUM_USE_PKG_CONFIG").is_ok()` return `true` (it checks *presence*, not *value*). Combined with `SODIUM_LIB_DIR` set in the workflow, the `libsodium-sys-stable` build script always hit the incompatibility panic. This is why every workflow-level fix (`unset`, `env -u`, different env var approaches) had zero effect — the variable was being re-injected by Cargo itself after exec. ## Fix Remove `SODIUM_USE_PKG_CONFIG = "0"` from the `[env]` block in `src-tauri/.cargo/config.toml`. The original comment claiming it "avoids memset_explicit on Windows" was incorrect — that variable controls detection strategy, not link behaviour. The actual Windows sodium handling is via `SODIUM_LIB_DIR` in the workflow. `SODIUM_STATIC = "1"` is retained as it controls static linking (correct for distribution).
sarman added 1 commit 2026-06-18 02:23:55 +00:00
fix(build): remove SODIUM_USE_PKG_CONFIG from .cargo/config.toml [env] block
Some checks failed
PR Review Automation / review (pull_request) Has been cancelled
Test / rust-clippy (pull_request) Has been cancelled
Test / frontend-tests (pull_request) Has been cancelled
Test / frontend-typecheck (pull_request) Has been cancelled
Test / rust-fmt-check (pull_request) Has been cancelled
Test / rust-tests (pull_request) Has been cancelled
8c29e7a7e3
Cargo injects [env] entries directly into build script environments,
bypassing shell-level unset and env -u entirely. SODIUM_USE_PKG_CONFIG
was set to "0" in [env], which libsodium-sys-stable build.rs treats as
"pkg-config enabled" (env::var().is_ok() returns true for any value
including "0"). Combined with SODIUM_LIB_DIR set in the workflow, this
triggered the incompatibility panic on every build.

The original comment claiming this "avoids memset_explicit on Windows"
was incorrect — SODIUM_USE_PKG_CONFIG controls detection strategy, not
link behaviour. The actual Windows memset_explicit fix is handled via
SODIUM_LIB_DIR pointing to pre-built MinGW sodium.
sarman merged commit ee909c9cf5 into beta 2026-06-18 02:24:59 +00:00
sarman deleted branch fix/cargo-config-sodium 2026-06-18 02:24:59 +00:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
1 Participants
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: sarman/tftsr-devops_investigation#114
No description provided.