Skip to content

Add the ability to set stdin for a Process#22976

Draft
svenier wants to merge 14 commits intopantsbuild:mainfrom
svenier:stdin
Draft

Add the ability to set stdin for a Process#22976
svenier wants to merge 14 commits intopantsbuild:mainfrom
svenier:stdin

Conversation

@svenier
Copy link
Copy Markdown

@svenier svenier commented Jan 5, 2026

This adds a new optional field to Process objects of the bytes to be passed into the command's stdin. This has the unfortunate side effect of forcing the command to run locally because the Remote Execution API doesn't support stdin (yet).

This is in support of #22918

Cursor written changes pass cargo testing, but python tests hang.
Committing to move to a new client that with a more consistent
python setup in case that hang is from the version problems.
Passes relevant cargo and pants tests.  Still needs to be tried
with a real build process.  Also needs a round of review &
cleanup of the Cursor generated code - especially the rust.
Delete a bunch of leftover logger calls
@svenier svenier changed the title WIP: Add this ability to set stdin for a Process WIP: Add the ability to set stdin for a Process Jan 5, 2026
Copy link
Copy Markdown
Contributor

@benjyw benjyw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this contribution! Some comments so far.

Remove superfluous comments, debug prints, and tests.
Default stdin on Process to None to preserve the distinction between
no stdin and stdin of a 0-byte string.
Error out on remote execution with stdin instead of forcing to local
@benjyw
Copy link
Copy Markdown
Contributor

benjyw commented Jan 10, 2026

Looks good overall. Let us know when this is out of Draft state and ready for a full review.

@svenier svenier marked this pull request as ready for review January 16, 2026 13:09
@svenier svenier changed the title WIP: Add the ability to set stdin for a Process Add the ability to set stdin for a Process Jan 16, 2026
@sureshjoshi sureshjoshi requested a review from benjyw January 16, 2026 13:52
Copy link
Copy Markdown
Contributor

@benjyw benjyw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks great, a clarification on a comment would be useful. Thanks!

@svenier
Copy link
Copy Markdown
Author

svenier commented Jan 18, 2026

Comments addressed. Question: Should the AI disclosure stay in the PR description above (which I think I read ends up in the commit message) or should it move to just a comment on the discussion?

@benjyw
Copy link
Copy Markdown
Contributor

benjyw commented Jan 19, 2026

Comments addressed. Question: Should the AI disclosure stay in the PR description above (which I think I read ends up in the commit message) or should it move to just a comment on the discussion?

Moving it to a comment makes sense.

Copy link
Copy Markdown
Contributor

@benjyw benjyw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Just one minor nit on one of the comments. Let me know when this is ready and I'll trigger one last CI run, and then merge on green.

@svenier
Copy link
Copy Markdown
Author

svenier commented Jan 19, 2026

AI Disclosure: Changes were made by an AI agent and review by multiple humans. Unfortunately, none of them are Rust experts, so some special attention is warranted there.

@svenier
Copy link
Copy Markdown
Author

svenier commented Jan 19, 2026

@benjyw All set! Thanks for your guidance on this.

Copy link
Copy Markdown
Contributor

@benjyw benjyw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more quick question.

Move use statement out of a local block up to the top of the file
@tdyas
Copy link
Copy Markdown
Contributor

tdyas commented Jan 20, 2026

Regarding REAPI support, Pants already has the ability to generate a wrapper script around remote executions. Stdin support would just be another item for the wrapper script to handle. See maybe_make_wrapper_script.

@svenier
Copy link
Copy Markdown
Author

svenier commented Jan 20, 2026

Regarding REAPI support, Pants already has the ability to generate a wrapper script around remote executions. Stdin support would just be another item for the wrapper script to handle. See maybe_make_wrapper_script.

Oh, hello! Can this be an improvement in a future version or should I flip this back to a draft so I don't merge it with the remote execution restriction in place?

@cburroughs cburroughs mentioned this pull request Jan 21, 2026
9 tasks
@tdyas
Copy link
Copy Markdown
Contributor

tdyas commented Jan 21, 2026

Regarding REAPI support, Pants already has the ability to generate a wrapper script around remote executions. Stdin support would just be another item for the wrapper script to handle. See maybe_make_wrapper_script.

Oh, hello! Can this be an improvement in a future version or should I flip this back to a draft so I don't merge it with the remote execution restriction in place?

In my view, it would depend on which release this PR ends up in. If it goes out as is in 2.31, then users would be able to observe a difference in behavior between local processes and remote execution processes. My vote would be to avoid that if we can.

But if it will go out in 2.32, then deferring the remote execution support to a separate PR seems fine.

@benjyw
Copy link
Copy Markdown
Contributor

benjyw commented Jan 21, 2026

@tdyas how complicated would it be to enhance that script? I'm guessing "not very"?

@tdyas
Copy link
Copy Markdown
Contributor

tdyas commented Jan 21, 2026

@tdyas how complicated would it be to enhance that script? I'm guessing "not very"?

Very straightforward:

  1. Modify maybe_make_wrapper_script to take an Option<String> with the stdin content filename to use. Add "has stdin content" as an additional reason to trigger use of the wrapper script. See

    if caches_fragment.is_none() && sandbox_root_fragment.is_none() {
    for the code which short-circuits use of the wrapper script if there is no need to do so.

  2. Modify the exec in the wrapper script to redirect from the stdin file if stdin filename is configured.

  3. Persist the stdin bytes to the CAS by updating wrapper_script_digest_opt to include a file for stdin content if there is such content. Use the filename that was passed in to maybe_make_wrapper_script.

@svenier
Copy link
Copy Markdown
Author

svenier commented Jan 21, 2026

Regarding REAPI support, Pants already has the ability to generate a wrapper script around remote executions. Stdin support would just be another item for the wrapper script to handle. See maybe_make_wrapper_script.

Oh, hello! Can this be an improvement in a future version or should I flip this back to a draft so I don't merge it with the remote execution restriction in place?

In my view, it would depend on which release this PR ends up in. If it goes out as is in 2.31, then users would be able to observe a difference in behavior between local processes and remote execution processes. My vote would be to avoid that if we can.

But if it will go out in 2.32, then deferring the remote execution support to a separate PR seems fine.

@cburroughs already asked to hold this until 2.32.

@svenier
Copy link
Copy Markdown
Author

svenier commented Jan 21, 2026

This is probably going to require a change to the UI since currently the Process object just gets Bytes for stdin, not a Digest.

Since that's a big of a big change, I'll flip this back to a draft and send out pings when I get the changes done.

@svenier svenier marked this pull request as draft January 21, 2026 14:25
@tdyas
Copy link
Copy Markdown
Contributor

tdyas commented Jan 21, 2026

This is probably going to require a change to the UI since currently the Process object just gets Bytes for stdin, not a Digest.

Since that's a big of a big change, I'll flip this back to a draft and send out pings when I get the changes done.

Bytes in the API is fine. Use the Store API to write the Bytes into the Digest with store_file_bytes as the existing wrapper script code does.

@svenier
Copy link
Copy Markdown
Author

svenier commented Jan 21, 2026

Bytes in the API is fine. Use the Store API to write the Bytes into the Digest with store_file_bytes as the existing wrapper script code does.

Sure, but if the Bytes were originally a file to begin with, it'd save a bunch of hassle to just pass the original Digest through.

@cburroughs
Copy link
Copy Markdown
Contributor

Thanks for the contribution. We've just branched for 2.31.x, so merging this pull request now will come out in 2.32.x, please move the release notes updates to docs/notes/2.32.x.md if that's appropriate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants