File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -24,9 +24,19 @@ function WARN() {
2424VENV_PATH=" ${VENV_PATH:-/ opt/ venv} "
2525export PATH=" ${VENV_PATH} /bin:$PATH "
2626
27+ # 配置 Rust 工具链目录,避免 Docker 中 HOME 与 root 真实主目录不一致时 rustup 无法推断路径。
28+ function configure_rust_build_env() {
29+ local home_dir=" ${HOME:-/ root} "
30+ export CARGO_HOME=" ${CARGO_HOME:- ${home_dir} / .cargo} "
31+ export RUSTUP_HOME=" ${RUSTUP_HOME:- ${home_dir} / .rustup} "
32+ if [[ " :${PATH} :" != * " :${CARGO_HOME} /bin:" * ]]; then
33+ export PATH=" ${CARGO_HOME} /bin:$PATH "
34+ fi
35+ }
36+
2737# 按需准备 Rust 构建环境,避免把工具链常驻打进 Docker runtime 镜像。
2838function ensure_rust_build_env() {
29- export PATH= " /root/.cargo/bin: $PATH "
39+ configure_rust_build_env
3040 if command -v cargo > /dev/null 2>&1 ; then
3141 return 0
3242 fi
@@ -47,7 +57,7 @@ function ensure_rust_build_env() {
4757 ERROR " 安装 Rust 工具链失败"
4858 return 1
4959 fi
50- export PATH= " /root/.cargo/bin: $PATH "
60+ configure_rust_build_env
5161 command -v cargo > /dev/null 2>&1
5262}
5363
You can’t perform that action at this time.
0 commit comments