10

Recently I got a new smartphone with fairly beefy specs, so wanting to play around with Rust on the go I installed Termux and tried to rustup-init. However, this fails:

info: syncing channel updates for 'stable-aarch64-linux-android'
info: latest update on 2017-08-31, rust version 1.20.0 (f3d6973f4 2017-08-27)
error: target not found: 'aarch64-linux-android'

Is there another way to get a Rust environment on android?

kmdreko
  • 42,554
  • 6
  • 57
  • 106
llogiq
  • 13,815
  • 8
  • 40
  • 72

3 Answers3

8

Sadly rustup won't work on android.

You can manage to install cargo and rustc using Termux.

Also if you have rustup already installed, rm .cargo will remove the stub (which otherwise interferes with calling cargo or rustc).

llogiq
  • 13,815
  • 8
  • 40
  • 72
Grégory OBANOS
  • 973
  • 8
  • 13
  • Cool! I was able to install stable, however running it only gives me 'error: no default toolchain configured'. – llogiq Sep 09 '17 at 20:37
  • 1
    Can you check the path of the rustc binary, it seems you still have a conflict with rustup. On my phone, the path is /data/data/com.termux/files/usr/bin/rustc – Grégory OBANOS Sep 09 '17 at 21:10
  • That was it! Thank you! – llogiq Sep 10 '17 at 08:42
  • This is very outdated... It's Pointless removed rustc, it's now in the main Repository. The Unstable Termux repository was deleted, and rustc-nightly is disabled due to an LLVM 12 incompatibility. You can still get Rustc-dev, but many packages will only build with experimental rustc-nightly features – Ray Foss Dec 15 '21 at 10:03
  • Thanks, Ray Foss, I updated the answer. – llogiq Jun 16 '23 at 15:52
2

There is a rust package available via pkg install rust. It contains Cargo and appears to install packages successfully.

The package source is here: https://github.com/termux/termux-packages/tree/master/packages/rust

Just a note: I had a binary failing to build during installation via Cargo due to libsqlite3-sys intermediate. This was solved by installing binutils package, which adds the archiver (ar) aarch64-linux-android-ar. The ecosystem is not flawless yet.

Alen Siljak
  • 2,482
  • 2
  • 24
  • 29
0

You can use rustup inside of a prooted distro. Example using arch linux:

pkg update && pkg upgrade
pkg in proot-distro
proot-distro install archlinux
proot-distro login archlinux
# Ideally you should now setup a non-root user, but i'll omit this step for brevity
sudo pacman -Syu base-devel --needed
sudo pacman -Syu rustup # it's better to install rustup from repo
rustup toolchain default stable
rustup update
# Now you have a working rustup installation, but it can only be used from inside the distro. Anyway, that's better than nothing.

I personally don't use termux's environment at all and do everything inside the distro, so you might prefer to do the same.

pew
  • 37
  • 2
  • 6