DioxusLabs / DioxusLabs/dioxus

Android: `dx serve --android` fails with "Failed to encode RUSTFLAGS" when NDK/linker path contains a space

Open Beginner friendly
#5,835 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
39.1k
Forks
1.9k
Avg merge
4d 10h
Merged PRs (30d)
4

Description

**Problem**
`dx serve --android` fails before cargo runs:

Build failed: Failed to encode RUSTFLAGS
```shell
1: flag in rustflags must not contain its separator (' ')
```

**Cause**
The Android rustflags for `clang_rt.builtins` are built as a single string:

```rust
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](https://github.com/DioxusLabs/dioxus/blob/main/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
```shell
$ 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).

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in packages/cli/src/build/android.rs at BuildRequest::android_env_vars(), where the clang_rt.builtins rustflags are assembled. Reproduce with an NDK path containing a space, then verify that the flags are encoded separately through CARGO_ENCODED_RUSTFLAGS and that dx serve --android proceeds past the RUSTFLAGS encoding failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, rust
Domain
cli, mobile-dev
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
88/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.