Android: `dx serve --android` fails with "Failed to encode RUSTFLAGS" when NDK/linker path contains a space
Author: devcompilCreated Sep 12, 2026Updated Sep 13, 2026
Problem
dx serve --android fails before cargo runs:
Build failed: Failed to encode RUSTFLAGS
1: flag in rustflags must not contain its separator (' ')Cause
The Android rustflags for clang_rt.builtins are built as a single string:
format!(
"-L{} -lstatic=clang_rt.builtins-{}-android",
clang_builtins_target.join("lib").join("linux").display(),
rt_builtins(&triple)
)Fichier : packages/cli/src/build/android.rs Fonction : BuildRequest::android_env_vars()
That string always contains a space (two flags concatenated). If the NDK path itself also has a space (Android SDK, username with space, etc.), cargo-config2 encode_space_separated rejects it.
Expected Split into two flags and encode with CARGO_ENCODED_RUSTFLAGS (\x1f), which allows spaces in paths.
Reproduction NDK path with a space
dx compilation error
$ dx serve android
...
[dev] Build failed: Failed to encode RUSTFLAGS
1: flag in rustflags must not contain its separator (' ')Workaround Symlink the SDK/NDK to a path without spaces (/opt/android/sdk).
Source: DioxusLabs/dioxus