为何arm32v7 Docker镜像中rustc二进制存在却无法执行?
问题:arm32v7镜像中Rust二进制存在但无法执行?
背景
基于arm32v7/python:3.11.5-slim-bullseye构建Docker镜像,因安装cryptography无预编译wheel需编译,故通过rustup安装Rust。
Dockerfile片段
# Install Rust with the install script RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y # Update path to include all Rust-related binaries ENV PATH="/root/.cargo/bin:${PATH}" RUN ls /root/.cargo/bin RUN /root/.cargo/bin/rustup --version RUN rustup --version RUN /root/.cargo/bin/rustc --version RUN rustc --version
执行现象
ls命令确认二进制存在:
#9 [ 5/14] RUN ls /root/.cargo/bin #9 0.441 cargo #9 0.441 cargo-clippy #9 0.441 cargo-fmt #9 0.441 cargo-miri #9 0.441 clippy-driver #9 0.441 rls #9 0.441 rust-analyzer #9 0.441 rust-gdb #9 0.441 rust-gdbgui #9 0.441 rust-lldb #9 0.441 rustc #9 0.441 rustdoc #9 0.441 rustfmt #9 0.441 rustup #9 DONE 1.1s
rustup --version执行异常:
#10 [ 6/14] RUN /root/.cargo/bin/rustup --version #10 0.584 rustup 1.26.0 (5af9b9484 2023-04-05) #10 0.584 info: This is the version for the rustup toolchain manager, not the rustc compiler. #10 0.685 info: The currently active `rustc` version is `(error reading rustc version)` #10 DONE 1.2s
rustc无法执行,即使指定绝对路径:
#12 [ 8/14] RUN /root/.cargo/bin/rustc --version #12 0.615 error: command failed: 'rustc': No such file or directory (os error 2) #12 ERROR: process "/bin/sh -c /root/.cargo/bin/rustc --version" did not complete successfully: exit code: 1
已尝试的解决方法
- 用
rustup run stable rustc -- --version执行,仍报相同的os error 2 - 将
rustc复制到其他路径执行,复制成功但仍无法运行 - 对
/root/.cargo/bin/rustc执行ldd,确认所有共享库存在 - 用
ls -l确认二进制不是符号链接:
#9 [ 5/15] RUN ls -l /root/.cargo/bin #9 0.482 total 182840 #9 0.482 -rwxr-xr-x 14 root root 13370420 Sep 23 15:44 cargo #9 0.482 -rwxr-xr-x 14 root root 13370420 Sep 23 15:44 cargo-clippy #9 0.482 -rwxr-xr-x 14 root root 13370420 Sep 23 15:44 cargo-fmt #9 0.482 -rwxr-xr-x 14 root root 13370420 Sep 23 15:44 cargo-miri #9 0.482 -rwxr-xr-x 14 root root 13370420 Sep 23 15:44 clippy-driver #9 0.482 -rwxr-xr-x 14 root root 13370420 Sep 23 15:44 rls #9 0.482 -rwxr-xr-x 14 root root 13370420 Sep 23 15:44 rust-analyzer #9 0.482 -rwxr-xr-x 14 root root 13370420 Sep 23 15:44 rust-gdb #9 0.482 -rwxr-xr-x 14 root root 13370420 Sep 23 15:44 rust-gdbgui #9 0.482 -rwxr-xr-x 14 root root 13370420 Sep 23 15:44 rust-lldb #9 0.482 -rwxr-xr-x 14 root root 13370420 Sep 23 15:44 rustc #9 0.482 -rwxr-xr-x 14 root root 13370420 Sep 23 15:44 rustdoc #9 0.482 -rwxr-xr-x 14 root root 13370420 Sep 23 15:44 rustfmt #9 0.482 -rwxr-xr-x 14 root root 13370420 Sep 23 15:44 rustup
- 通过
rustup安装不同版本工具链,无任何变化
期望
rustc二进制文件能正常被找到并执行。
内容的提问来源于stack exchange,提问作者user22400056
相关产品推荐
相关产品推荐

