Skip to content

[codex] Make justfile recipes Windows-aware#24983

Open
iceweasel-oai wants to merge 11 commits into
mainfrom
codex/windows-justfile-recipes
Open

[codex] Make justfile recipes Windows-aware#24983
iceweasel-oai wants to merge 11 commits into
mainfrom
codex/windows-justfile-recipes

Conversation

@iceweasel-oai
Copy link
Copy Markdown
Collaborator

@iceweasel-oai iceweasel-oai commented May 28, 2026

Summary

Make the root justfile usable from Windows without maintaining a separate Windows copy of most recipes.

The repo recipes previously assumed POSIX shell behavior for things like variadic argument forwarding ("$@") and stderr redirection (2>/dev/null). That made common workflows such as just fmt, just test, and just log unreliable from Windows. This PR introduces a small cross-platform shell adapter so recipes can stay mostly unified while still expanding the few shell-specific constructs correctly on macOS/Linux and Windows.

What Changed

  • Add scripts/just-shell.py as the configured just shell adapter.
    • On Unix it invokes sh -cu.
    • On Windows it invokes pwsh -CommandWithArgs so arguments containing spaces are preserved.
  • Add portable recipe placeholders:
    • {args} expands to "$@" on Unix and the equivalent PowerShell forwarded-args expression on Windows.
    • {stderr-null} expands to the platform-specific stderr suppression used by fmt.
  • Convert most variadic one-line recipes to the unified {args} form, including codex, exec, file-search, app-server-test-client, fix, clippy, bench, mcp-server-run, write-app-server-schema, and argument-comment-lint-from-source.
  • Keep genuinely shell-specific recipes split or Unix-only for now, including recipes backed by .sh scripts or recipes whose bodies are more than simple command forwarding.
  • Add a Windows just install path that installs PowerShell via winget when pwsh is not available, then runs the same basic Rust setup steps.
  • Update the SDK test that validates the root fmt recipe so it recognizes the new portable stderr placeholder.

Validation

  • just --summary
  • just --dry-run fmt
  • just --dry-run bench-smoke
  • just --dry-run codex foo "bar binky" baz
  • just --dry-run write-hooks-schema
  • just --dry-run bazel-lock-update
  • just --dry-run argument-comment-lint-from-source -- "foo bar"
  • git diff --check -- justfile scripts/just-shell.py sdk/python/tests/test_artifact_workflow_and_binaries.py
  • Verified Windows argv preservation through scripts/just-shell.py with arguments containing spaces.
  • uv run --frozen --project sdk/python --extra dev pytest sdk/python/tests/test_artifact_workflow_and_binaries.py::test_root_fmt_recipe_formats_rust_and_python_sdk

@iceweasel-oai iceweasel-oai requested a review from bolinfest May 28, 2026 23:09
@iceweasel-oai iceweasel-oai force-pushed the codex/windows-justfile-recipes branch from 23a47b5 to 8f4cc03 Compare May 28, 2026 23:12
Copy link
Copy Markdown
Contributor

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 23a47b5ccc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread justfile Outdated
Comment thread justfile Outdated
Comment thread justfile Outdated
Comment thread justfile Outdated
[windows]
app-server-test-client *args:
cargo build -p codex-cli
cargo run -p codex-app-server-test-client -- --codex-bin ./target/debug/codex {{args}}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge Do not expose the Unix-only app-server serve helper on Windows

This Windows recipe forwards all app-server-test-client subcommands, but serve is still implemented with Unix-only assumptions (/tmp/codex-app-server-test-client, nohup, sh -c, and tail -f /dev/null in codex-rs/app-server-test-client/src/lib.rs). On a stock Windows machine, just app-server-test-client serve now selects this advertised Windows recipe and then fails before starting the server, so the recipe needs to guard or avoid the unsupported subcommand until there is a Windows implementation.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator

@bolinfest bolinfest left a comment

Choose a reason for hiding this comment

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

The justfile does not feel maintainable to me in this form. It is unfortunate that its handling of varargs is so terrible.

Most of our commands are single lines of POSIX shell. I think we should introduce a Python script that can take such a line and rewrite it for PowerShell/cmd.exe as necessary.

Example:

exec *args:
    python3 just.py 'cargo run --bin codex -- exec "$@"'

Comment thread scripts/just-shell.py
Comment on lines +42 to +45
return subprocess.run(
["sh", "-cu", command, recipe_name, *recipe_args],
check=False,
).returncode
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can we use exec so it replaces the process?

Suggested change
return subprocess.run(
["sh", "-cu", command, recipe_name, *recipe_args],
check=False,
).returncode
os.execvp("sh", ["sh", "-cu", command, recipe_name, *recipe_args])

actual = {
"working_directory": lines[0],
"previous_attribute": lines[fmt_index - 1],
"previous_comment": next(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Does this file have to change because of changes to the justfile?

Comment thread justfile
[unix]
[no-cd]
bazel-lock-check:
{{ justfile_directory() }}/scripts/check-module-bazel-lock.sh
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can be done in a follow-up, but maybe this should be a platform-independent Python script?

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.

2 participants