Cargo: Cargo fails in Linux chroot without /proc

Created on 30 Aug 2017  路  6Comments  路  Source: rust-lang/cargo

...
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"...

A-build-execution C-bug Command-build O-linux stale

All 6 comments

Hm I sort of forget at this point what we're even using that for. Maybe we can just remove the dependence on calling current_exe?

@alexcrichton found it! https://github.com/rust-lang/cargo/issues/3778#issuecomment-283448233

Maybe we could use a method other than env::current_exe for this case? Or just let the user specify CARGO and check if that's present, and if so, use it instead of calling current_exe?

I need to read more context first. We're only setting this for external subcommands so we don't _use_ it ourselves per se, but yeah; we could just check if it's set already and not do anything if so, letting the environment propagate.

Example of the latter at #4634.

As there hasn't been any activity here in over 6 months I've marked this as stale and if no further activity happens for 7 days I will close it.

I'm a bot so this may be in error! If this issue should remain open, could someone (the author, a team member, or any interested party) please comment to that effect?

The team would be especially grateful if such a comment included details such as:

  • Is this still relevant?
  • If so, what is blocking it?
  • Is it known what could be done to help move this forward?

Thank you for contributing!

(The cargo team is currently evaluating the use of Stale bot, and using #6035 as the tracking issue to gather feedback.)

If you're reading this comment from the distant future, fear not if this was closed automatically. If you believe it's still an issue please leave a comment and a team member can reopen this issue. Opening a new issue is also acceptable!

As I didn't see any updates in 30 days I'm going to close this. Please see the previous comment for more information!

Was this page helpful?
0 / 5 - 0 ratings