rustc "unexpected panic"; no /proc/self/exe inside a debootstrap chroot
I installed rustc in a Debian chroot, as per https://wiki.debian.org/Debootstrap
sudo debootstrap testing /debian-testing-chroot https://deb.debian.org/debian/
Inside that chroot, rustc crashes.
# rustc hello.rs
Can't read /proc/cpuinfo: No such file or directory
error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: rustc 1.21.0 running on x86_64-unknown-linux-gnu
thread 'rustc' panicked at 'failed to get current_exe: no /proc/self/exe available. Is /proc mounted?', src/librustc/session/filesearch.rs:169:22
note: Run with `RUST_BACKTRACE=1` for a backtrace.
# ls /proc
#
Sure, I can tinker with my chroot configuration to flesh out /proc, but as rustc's output said, "the compiler unexpectedly panicked. this is a bug".
RUST_BACKTRACE=1 doesn't give much information.
# RUST_BACKTRACE=1 rustc hello.rs Can't read /proc/cpuinfo: No such file or directory error: internal compiler error: unexpected panic note: the compiler unexpectedly panicked. this is a bug. note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports note: rustc 1.21.0 running on x86_64-unknown-linux-gnu note: run with `RUST_BACKTRACE=1` for a backtrace thread 'rustc' panicked at 'failed to get current_exe: no /proc/self/exe available. Is /proc mounted?', src/librustc/session/filesearch.rs:169:22 stack backtrace: 0: <unknown> 1: <unknown> 2: <unknown> 3: <unknown> 4: <unknown> 5: <unknown> 6: <unknown> 7: <unknown> 8: <unknown> 9: <unknown> 10: <unknown> 11: <unknown> 12: <unknown> 13: <unknown> 14: <unknown> 15: <unknown>Nigel Tao at 2017-11-19 02:19:02
Getting the same when building cryptography for python.
rustc' panicked at 'failed to get current_exe: no /proc/self/exe available. Is /proc mountedSource at this project: https://github.com/guysoft/MagicMirrorOS
Guy Sheffer at 2021-04-08 15:46:12
I'm having the same issue when compiling a simple rust program inside a sandbox. The error I get is:
error: Unable to proceed. Could not locate working directory.: no /proc/self/exe available. Is /proc mounted?The simple rust program I'm trying to compile is:
fn main() { println!("Hey there!"); }Is there any workaround to avoid mounting proc inside the sandbox?
Source of the sandbox: https://github.com/alerighi/tabox
filippoSelvatici at 2021-09-30 09:03:47
We need
/proc/self/exeto implementstd::env::current_exe()which rustc uses to locate the sysroot.bjorn3 at 2022-05-15 17:26:43
@bjorn3 that is going to be a problem, because some sandboxes (such as Sandstorm) deliberately avoid mounting
/procto reduce attack surface. I thinkrustcshould have a compiled-in fallback if/procis not mounted.Demi Marie Obenour at 2022-05-25 04:01:27
You can pass
--sysrootto manually specify the sysroot location. Rustc can't have a builtin fallback as there is no stamdard location to install it. Some put it in/usr, others in/usr/localamd rustup puts it in~/.rustup/toolchains/<toolchain name>.bjorn3 at 2022-05-25 06:49:02
Also note that libc itself needs
/procto be mounted for certain things. For example musl libc needs it forttynameand both glibc and musl need it forfchmodat. In both cases to pass an fd to a syscall expecting a path using/proc/self/fd.bjorn3 at 2022-05-25 07:10:38