Skip to content

Cargo fails in Linux chroot without /proc #4450

Closed
@apaprocki

Description

@apaprocki
...
running: /tmp/rust-1.19-1.19.0-0/build/x86_64-unknown-linux-gnu/stage0/bin/cargo build \
    --manifest-path /tmp/rust-1.19-1.19.0-0/src/bootstrap/Cargo.toml --verbose
error: couldn't get the path to cargo executable

This is due to this code:

    pub fn cargo_exe(&self) -> CargoResult<&Path> {
        self.cargo_exe.get_or_try_init(||
            env::current_exe().and_then(|path| path.canonicalize())
            .chain_err(|| "couldn't get the path to cargo executable")
        ).map(AsRef::as_ref)
    }

Which ultimately calls this code:

#[cfg(any(target_os = "linux", target_os = "android", target_os = "emscripten"))]
pub fn current_exe() -> io::Result<PathBuf> {
    let selfexe = PathBuf::from("/proc/self/exe");
    if selfexe.exists() {
        ::fs::read_link(selfexe)
    } else {
        Err(io::Error::new(io::ErrorKind::Other, "no /proc/self/exe available. Is /proc mounted?"))
    }
}

Is the project open to modifying this logic to allow the full path to the executable to be specified via config or environment variable if /proc intentionally does not exist?

Something along the lines of CARGO_EXE or [build] cargo = "/path/to/cargo"...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions