BrainiumLLC / cargo-mobile

Rust on mobile made easy!
Apache License 2.0
1.24k stars 52 forks source link

`cargo android run` does not respect `$*_HOME` #122

Open mamins1376 opened 1 year ago

mamins1376 commented 1 year ago

I have set $RUSTUP_HOME and $CARGO_HOME to non-default values in my setup, and trying to build for android gave me the following results:

$ cargo android run
...
error: rustup could not choose a version of cargo to run, because one wasn't specified explicitly, and no default is configured.
help: run 'rustup default stable' to download the latest stable release of Rust and set it as your default toolchain.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:rustBuildArm64Debug'.
> Process 'command 'cargo'' finished with non-zero exit value 1

After some investigation, turns out cargo-android does not pass RUSTUP_HOME and CARGO_HOME environment variables down, resulting in the above error.

Current workaround: Make a symlink for each non-default path to the current one:

$ cd
$ rm -rf .rustup
$ ln -sr "$RUSTUP_HOME" .rustup
$ rm -rf .cargo
$ ln -sr "$CARGO_HOME" .cargo