Skip to content

Tracking Issue for command_resolve #141976

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
3 tasks
ChrisDenton opened this issue Jun 3, 2025 · 0 comments
Open
3 tasks

Tracking Issue for command_resolve #141976

ChrisDenton opened this issue Jun 3, 2025 · 0 comments
Labels
C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC T-libs Relevant to the library team, which will review and decide on the PR/issue.

Comments

@ChrisDenton
Copy link
Member

Feature gate: #![feature(command_resolve)]

This is a tracking issue for providing more control of Command's resolution of executable files. See ACP#591

The libs-api team were divided on the shape and scope of this feature so this experiment explores multiple options in order to gather feedback. Please provide feedback if any of these are useful to you or you have other ideas.

Public API

// in std::process

/// Resolve the program to an absolute path by searching
/// the given paths for the executable.
pub fn resolve_exe(program: S, paths: I) -> io::Result<PathBuf>
where
S: AsRef<Path>.
I: IntoIterator<Item = P>,
P: AsRef<Path>,
{/*...*/

impl Command {
    /// Resolve the program by searching only the given paths for the executable.
    /// `paths` should be in the same format as `PATH`.
    fn resolve_in_paths(&mut self, paths: impl AsRef<OsStr>) -> &mut Self;

    /// If `PATH` is set on the child and `program` is not a path
    /// then force the program to be resolved as if the child `PATH` wasn't set.
    /// E.g. on Unix this may use `posix_spawn`.
    fn resolve_in_parent_path(&mut self, use_parent: bool) -> &mut Self;
}

Steps / History

(Remember to update the S-tracking-* label when checking boxes.)

  • Implementation: #...
  • Final comment period (FCP)1
  • Stabilization PR

Unresolved Questions

  • What shape should this API ultimately have?
  • Instead of this. should we have platform-specific extensions for change the executable resolution in platform specific ways?
  • Does this commit us, on every target, to always implement our own path resolution? (On some targets, we may be able to just defer to the OS for the actual execution, but these functions may still require reimplementing path resolution.)
  • What about chroot? Should our path resolution take that into account, and what should it return?
  • What about future extensions letting us use execveat/fexecve, where there's a file descriptor but no path?
  • After the path is resolved, should the Command avoid re-resolving it, by reusing the resolution (e.g. to avoid a TOCTTOU)?

Footnotes

  1. https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html

@ChrisDenton ChrisDenton added C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jun 3, 2025
rust-bors bot added a commit that referenced this issue Jun 5, 2025
Add `Command::resolve_in_parent_path`

This is part of #141976 (ACP: rust-lang/libs-team#591). libs-api could not come to a consensus on what the final API should look like so they've agreed to experiment with a few different approaches.

This PR just implements the `resolve_in_parent_path` method which forces `Command` to ignore `PATH` set on the child for the purposes of resolving the executable. There was no consensus on what should happen if, for example, `chroot` is set (which can change the meaning of paths) so for now I've just done the easy thing. Figuring out the correct behaviour here will need to be done before this is considered for stabilisation but hopefully having it on nightly will nudge people in to giving their opinions.
try-job: `aarch64-apple`
try-job: `x86_64-msvc-*`
try-job: `dist-various-*`
rust-bors bot added a commit that referenced this issue Jun 5, 2025
Add `Command::resolve_in_parent_path`

This is part of #141976 (ACP: rust-lang/libs-team#591). libs-api could not come to a consensus on what the final API should look like so they've agreed to experiment with a few different approaches.

This PR just implements the `resolve_in_parent_path` method which forces `Command` to ignore `PATH` set on the child for the purposes of resolving the executable. There was no consensus on what should happen if, for example, `chroot` is set (which can change the meaning of paths) so for now I've just done the easy thing. Figuring out the correct behaviour here will need to be done before this is considered for stabilisation but hopefully having it on nightly will nudge people in to giving their opinions.
try-job: aarch64-apple
try-job: x86_64-msvc-*
try-job: dist-various-*
rust-bors bot added a commit that referenced this issue Jun 5, 2025
Add `Command::resolve_in_parent_path`

This is part of #141976 (ACP: rust-lang/libs-team#591). libs-api could not come to a consensus on what the final API should look like so they've agreed to experiment with a few different approaches.

This PR just implements the `resolve_in_parent_path` method which forces `Command` to ignore `PATH` set on the child for the purposes of resolving the executable. There was no consensus on what should happen if, for example, `chroot` is set (which can change the meaning of paths) so for now I've just done the easy thing. Figuring out the correct behaviour here will need to be done before this is considered for stabilisation but hopefully having it on nightly will nudge people in to giving their opinions.
try-job: `x86_64-msvc-*`
try-job: `dist-various-*`
rust-bors bot added a commit that referenced this issue Jun 5, 2025
Add `Command::resolve_in_parent_path`

This is part of #141976 (ACP: rust-lang/libs-team#591). libs-api could not come to a consensus on what the final API should look like so they've agreed to experiment with a few different approaches.

This PR just implements the `resolve_in_parent_path` method which forces `Command` to ignore `PATH` set on the child for the purposes of resolving the executable. There was no consensus on what should happen if, for example, `chroot` is set (which can change the meaning of paths) so for now I've just done the easy thing. Figuring out the correct behaviour here will need to be done before this is considered for stabilisation but hopefully having it on nightly will nudge people in to giving their opinions.
try-job: `x86_64-msvc-*`
try-job: `dist-various-*`
rust-bors bot added a commit that referenced this issue Jun 5, 2025
Add `Command::resolve_in_parent_path`

This is part of #141976 (ACP: rust-lang/libs-team#591). libs-api could not come to a consensus on what the final API should look like so they've agreed to experiment with a few different approaches.

This PR just implements the `resolve_in_parent_path` method which forces `Command` to ignore `PATH` set on the child for the purposes of resolving the executable. There was no consensus on what should happen if, for example, `chroot` is set (which can change the meaning of paths) so for now I've just done the easy thing. Figuring out the correct behaviour here will need to be done before this is considered for stabilisation but hopefully having it on nightly will nudge people in to giving their opinions.
try-job: `x86_64-msvc-*`
try-job: `dist-various-*`
rust-bors bot added a commit that referenced this issue Jun 5, 2025
Add `Command::resolve_in_parent_path`

This is part of #141976 (ACP: rust-lang/libs-team#591). libs-api could not come to a consensus on what the final API should look like so they've agreed to experiment with a few different approaches.

This PR just implements the `resolve_in_parent_path` method which forces `Command` to ignore `PATH` set on the child for the purposes of resolving the executable. There was no consensus on what should happen if, for example, `chroot` is set (which can change the meaning of paths) so for now I've just done the easy thing. Figuring out the correct behaviour here will need to be done before this is considered for stabilisation but hopefully having it on nightly will nudge people in to giving their opinions.
try-job: `x86_64-msvc-*`
try-job: `dist-various-*`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

1 participant