安装
-
安装
1└──╼ brew install rustup 2└──╼ rustup-init 3...... 41) Proceed with installation (default) 52) Customize installation 63) Cancel installation 7>1 -
配置 rust 目录
1└──╼ mkdir $HOME/repo/rust 2└──╼ mv $HOME/.rustup $HOME/repo/rust/rustup 3└──╼ mv $HOME/.cargo $HOME/repo/rust/cargo写入 .bashrc 文件
1export RUSTUP_HOME=$HOME/repo/rust/rustup 2export CARGO_HOME=$HOME/repo/rust/cargo 3export PATH=$PATH:$HOME/repo/rust/cargo/bin -
验证
1└──╼ source .bashrc 2└──╼ cargo --version 3cargo 1.46.0 (149022b1d 2020-07-17)
更新
最近在测试时发现无法安装 tauri-app, 需要更新 cargo
1Caused by:
2 failed to parse the `edition` key
3
4Caused by:
5 this version of Cargo is older than the `2021` edition, and only supports `2015` and `2018` editions.
解决方式
1└──╼ rustc --version
2rustc 1.46.0 (04488afe3 2020-08-24)
3└──╼ rustup update stable
4...
5└──╼ rustc --version
6rustc 1.64.0 (a55dd71d5 2022-09-19)
交叉编译
1brew install FiloSottile/musl-cross/musl-cross
2rustup target add x86_64-unknown-linux-musl
添加配置 $CARGO_HOME/config.toml
1[target.x86_64-unknown-linux-musl]
2linker = "x86_64-linux-musl-gcc"
1cargo build --target=x86_64-unknown-linux-musl
知识共享署名-非商业性使用-相同方式共享4.0国际许可协议