Skip to content

fix(setup): persist GitHub Actions env files - #12841

Merged
zkochan merged 11 commits into
pnpm:mainfrom
scarab-systems:fix-pnpm-9191-global-bin-dir
Jul 24, 2026
Merged

zkochan merged 11 commits into
pnpm:mainfrom
scarab-systems:fix-pnpm-9191-global-bin-dir

Conversation

@scarab-systems

@scarab-systems scarab-systems commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #9191.

  • Persist PNPM_HOME to the GitHub Actions environment file during pnpm setup.
  • Persist the setup bin directory to the GitHub Actions path file for later workflow steps.
  • Keep the TypeScript CLI and Rust pacquet/ setup behavior aligned.

Squash Commit Body

Write PNPM_HOME to the GitHub Actions environment file.

Add the setup bin directory to the workflow path file.

Later workflow steps can use global pnpm commands.

Keep TypeScript setup and pacquet setup behavior aligned.

Refs pnpm/pnpm#9191.

Checklist

  • The change is implemented in both the TypeScript CLI and the Rust pacquet/ port.
  • Added a changeset.
  • Added or updated tests.
  • Documentation update not needed.

Disclosure: I used AI-assisted coding tools while preparing this PR. I reviewed the changes myself, tested them, and take responsibility for the implementation and any follow-up revisions needed.

If this project does not accept AI-assisted contributions, please let us know up front so we can avoid spending time on a contribution that the project is unwilling to consider.

Summary by CodeRabbit

  • New Features
    • pnpm setup now persists PNPM_HOME and the pnpm global bin directory to GitHub Actions GITHUB_ENV/GITHUB_PATH files when running under GitHub Actions and those targets are provided.
    • Input values are validated to prevent unsafe newline/carriage-return/NUL characters; write issues are reported as warnings while setup continues.
    • The same GitHub Actions env-file persistence is added for pacquet setup.
  • Tests
    • Added/expanded Jest/unit tests covering env-file writing and appending, GitHub Actions gating and isolation, independent updates, no file creation when targets are missing, and rejection of invalid values.

@coderabbitai

coderabbitai Bot commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds GitHub Actions env-file persistence to pnpm setup and pacquet setup, writing PNPM_HOME and the global bin directory when runner-provided outputs are available, with validation, warnings, tests, and release notes.

Changes

GitHub Actions setup persistence

Layer / File(s) Summary
Release note entry
.changeset/pnpm-setup-github-actions.md
Adds a patch changeset and notes GitHub Actions environment-file persistence for PNPM_HOME and the global bin directory.
TypeScript setup persistence
pnpm11/engine/pm/commands/src/setup/setup.ts
Adds GitHub Actions gating, value validation, append-only writes to GITHUB_ENV/GITHUB_PATH, warning logging, and handler wiring after addDirToEnvPath.
Rust setup persistence
pacquet/crates/cli/Cargo.toml, pacquet/crates/cli/src/cli_args/setup.rs
Adds Unix dependency support and GitHub Actions gating, value validation, append-only writes to GITHUB_ENV/GITHUB_PATH, warning logging, and handler wiring.
TypeScript setup tests
pnpm11/engine/pm/commands/test/setup/setup.test.ts
Adds environment isolation and tests for GitHub Actions file writing, no-op behavior, missing targets, independent writes, failure warnings, and invalid values.
Rust setup tests
pacquet/crates/cli/src/cli_args/setup/tests.rs
Adds imports and unit tests for file writing, no-op behavior, independent writes, failure warnings, and invalid values.

Estimated code review effort: 4 (Complex) | ~45 minutes

Assessment against linked issues

Objective Addressed Explanation
[#9191] Persist PNPM_HOME across pnpm setup on GitHub Actions and keep the global bin directory usable for pnpm add --global ✅
[#9191] Make pnpm setup work under corepack enable on GitHub Actions ✅
[#9191] Avoid requiring manual SHELL handling during pnpm setup on GitHub Actions ❓ The diff adds env-file persistence, but it does not show shell detection or SHELL handling changes.

Out-of-scope changes

Code Change Explanation
Doc comment formatting change in generate_pwsh_shim (pacquet/crates/cmd-shim/src/shim.rs:262) This only changes documentation formatting and is unrelated to the GitHub Actions setup behavior.

Suggested labels: product: pacquet, product: pnpm@11

Suggested reviewers: zkochan

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change: persisting GitHub Actions env files during setup.
Description check ✅ Passed The description follows the template with Summary, Squash Commit Body, and checklist items filled out.
Linked Issues check ✅ Passed The code addresses the issue by persisting PNPM_HOME and the bin path to GitHub Actions env files in both TS and Rust.
Out of Scope Changes check ✅ Passed The PR stays focused on GitHub Actions setup persistence, tests, changeset, and the Rust/TypeScript alignment needed for it.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@scarab-systems
scarab-systems marked this pull request as ready for review July 7, 2026 14:38
@scarab-systems
scarab-systems requested a review from zkochan as a code owner July 7, 2026 14:38
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

fix(setup): persist PNPM_HOME and bin dir via GitHub Actions env/path files

🐞 Bug fix 🧪 Tests 🕐 20-40 Minutes

Grey Divider

AI Description

• Persist PNPM_HOME and the setup bin directory for later GitHub Actions steps.
• Implement the same behavior in both TypeScript CLI and Rust pacquet setup.
• Add coverage to verify the correct environment/path files are written.
Diagram

graph TD
  A["pnpm setup (TS/Rust)"] --> B["Compute PNPM_HOME + bin"] --> C["Update shell PATH (path-extender)"] --> D{"Running in GitHub Actions?\n(GITHUB_ENV & GITHUB_PATH set)"}
  D -- "yes" --> E["/Append PNPM_HOME to $GITHUB_ENV/"] --> F["/Append bin dir to $GITHUB_PATH/"]
  D -- "no" --> G["No CI persistence"]

  subgraph Legend
    direction LR
    _svc["Command/logic"] ~~~ _dec{"Decision"} ~~~ _file["/Env file/"]
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Leave GitHub Actions persistence to workflow YAML
2. Emit GitHub Actions workflow commands (legacy ::add-path/::set-env)
  • ➕ Does not require file IO and can be done via stdout.
  • ➖ Those commands are deprecated/disabled for security; environment files are the recommended mechanism.
  • ➖ More brittle across runner versions and security settings.

Recommendation: Keep the PR’s approach: writing to GITHUB_ENV and GITHUB_PATH when present is the GitHub-recommended mechanism for persisting environment and PATH across steps, and it directly fixes #9191 with minimal risk. The alternative of pushing responsibility to workflow YAML would perpetuate footguns, and legacy workflow commands are not a viable long-term option.

Files changed (5) +115 / -3

Bug fix (2) +45 / -1
setup.rsPersist PNPM_HOME and bin dir into GitHub Actions env/path files (Rust) +34/-1

Persist PNPM_HOME and bin dir into GitHub Actions env/path files (Rust)

• Adds GitHub Actions detection via 'GITHUB_ENV'/'GITHUB_PATH' and appends 'PNPM_HOME=...' plus the bin directory to those files during 'setup'. Implements a small helper ('write_github_actions_environment_files') and wires it into the main handler after PATH setup.

pacquet/crates/cli/src/cli_args/setup.rs

setup.tsAppend PNPM_HOME and bin dir to GitHub Actions env/path files (TS) +11/-0

Append PNPM_HOME and bin dir to GitHub Actions env/path files (TS)

• Adds 'writeGitHubActionsEnvironmentFiles()' that appends 'PNPM_HOME' to 'GITHUB_ENV' and the setup bin dir to 'GITHUB_PATH' when those variables are present. Invokes the helper from the 'setup' handler to persist settings across workflow steps.

pnpm11/engine/pm/commands/src/setup/setup.ts

Tests (2) +64 / -2
tests.rsAdd Rust test for GitHub Actions environment/path file output +22/-1

Add Rust test for GitHub Actions environment/path file output

• Adds a unit test that writes to temp 'github-env'/'github-path' files and asserts 'PNPM_HOME' and bin directory are appended with trailing newlines.

pacquet/crates/cli/src/cli_args/setup/tests.rs

setup.test.tsAdd Jest coverage for GitHub Actions persistence in setup +42/-1

Add Jest coverage for GitHub Actions persistence in setup

• Adds test scaffolding to safely modify/restore 'GITHUB_ENV' and 'GITHUB_PATH' across tests, and introduces a new test that verifies 'setup.handler()' writes the expected contents to the env/path files.

pnpm11/engine/pm/commands/test/setup/setup.test.ts

Documentation (1) +6 / -0
pnpm-setup-github-actions.mdAdd changeset for GitHub Actions persistence in 'pnpm setup' +6/-0

Add changeset for GitHub Actions persistence in 'pnpm setup'

• Introduces a patch changeset for both 'pnpm' and '@pnpm/engine.pm.commands' documenting that 'pnpm setup' now persists 'PNPM_HOME' and the global bin directory via GitHub Actions environment files.

.changeset/pnpm-setup-github-actions.md

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Jul 7, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (4) 📘 Rule violations (0) 📎 Requirement gaps (1) 📜 Skill insights (0)

Context used

Grey Divider


Remediation recommended

1. GITHUB_ENV may miss newline 📎 Requirement gap ☼ Reliability ⭐ New
Description
appendGitHubActionsEnvironmentFile() / append_existing_regular_file() appends PNPM_HOME=...
and PATH/bin-dir entries at the current file size without ensuring the target GitHub Actions
env/path file ends with a newline, so the new record can be concatenated onto the previous final
line. This can break GitHub Actions parsing and prevent PNPM_HOME/PATH from persisting across
steps, causing later global commands to fail.
Code

pnpm11/engine/pm/commands/src/setup/setup.ts[R168-172]

+    const fd = fs.openSync(filePath, 'r+')
+    try {
+      const { size } = fs.fstatSync(fd)
+      fs.writeSync(fd, `${line}\n`, size, 'utf8')
+    } finally {
Evidence
Compliance/checklist requirements state that after pnpm setup, subsequent GitHub Actions steps
must have PNPM_HOME and the global bin directory on PATH. The cited code appends ${line}\n (or
uses writeln!) by writing at offset size but does not verify whether a non-empty existing file
is newline-terminated; if the last byte is not \n, the appended PNPM_HOME=... or PATH/bin-dir
line can merge with the previous record, making the env/path file invalid for GitHub Actions to
parse and thus preventing persistence into later steps.

GitHub Actions: pnpm global installs work after corepack enable + pnpm setup
GitHub Actions: PNPM_HOME persists across steps after pnpm setup and sourcing shell config
pnpm11/engine/pm/commands/src/setup/setup.ts[158-172]
pacquet/crates/cli/src/cli_args/setup.rs[152-161]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
When appending records to GitHub Actions environment/path files, the implementation writes the new `PNPM_HOME=...` and PATH/bin-dir entries at the current file size but does not ensure the existing file ends with a newline. If the file is non-empty and its last byte is not `\n`, the newly appended record can be concatenated onto the previous final line and become invalid, which can break GitHub Actions parsing and prevent cross-step persistence.

## Issue Context
Compliance/checklist expectations require `PNPM_HOME` and the pnpm global bin directory to persist across GitHub Actions steps after `pnpm setup`, so later workflow steps can successfully run global pnpm commands. A missing trailing newline in the target env/path file can cause appended entries to merge with the prior entry and be ignored or misparsed.

## Fix Focus Areas
- pnpm11/engine/pm/commands/src/setup/setup.ts[158-174]
- pacquet/crates/cli/src/cli_args/setup.rs[152-162]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Non-atomic env-file append 🐞 Bug ☼ Reliability ⭐ New
Description
In the TypeScript CLI, appendGitHubActionsEnvironmentFile() implements “append” by fstat() +
writeSync() at an explicit offset on an fd opened with 'r+', so concurrent writers can race and
overwrite/garble the tail of $GITHUB_ENV/$GITHUB_PATH. This can intermittently corrupt the runner
env files and cause later workflow steps to miss PNPM_HOME / PATH updates.
Code

pnpm11/engine/pm/commands/src/setup/setup.ts[R168-172]

+    const fd = fs.openSync(filePath, 'r+')
+    try {
+      const { size } = fs.fstatSync(fd)
+      fs.writeSync(fd, `${line}\n`, size, 'utf8')
+    } finally {
Evidence
The TS implementation writes at a specific byte offset derived from fstatSync(), which is not an
atomic append and can race with other appenders. In contrast, the Rust port uses OS append mode
(OpenOptions::append(true)), highlighting the safer pattern already used elsewhere in this PR.

pnpm11/engine/pm/commands/src/setup/setup.ts[158-174]
pacquet/crates/cli/src/cli_args/setup.rs[152-161]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`appendGitHubActionsEnvironmentFile()` opens the env/path file with `'r+'`, computes the file size, then writes at that position. This is not an atomic append; if another process writes between `fstatSync()` and `writeSync()`, the write can land in the middle of newly-appended content and corrupt the file.

### Issue Context
This code runs specifically to update GitHub Actions runner files (`$GITHUB_ENV` / `$GITHUB_PATH`). These files are designed for line-appends, and GitHub Actions workflows commonly run multiple tools that may append to them in the same step.

### Fix Focus Areas
- pnpm11/engine/pm/commands/src/setup/setup.ts[158-174]

### Suggested change
- After confirming the path is a regular file, open the file in OS append mode (e.g. `fs.openSync(filePath, fs.constants.O_WRONLY | fs.constants.O_APPEND)`), and write with `position = null` (or without specifying a position).
- Keep the “don’t create missing files” behavior by **not** including `O_CREAT`.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. TOCTOU file swap window 🐞 Bug ⛨ Security ⭐ New
Description
Both implementations check that $GITHUB_ENV/$GITHUB_PATH is a regular file and then open it in a
separate step, leaving a time-of-check/time-of-use window where the path could be swapped (e.g.,
replaced with a symlink) between the check and open. Under a threat model where an attacker can
influence these env vars and the filesystem while pnpm runs with higher privileges, this can
redirect the append into an unintended file.
Code

pnpm11/engine/pm/commands/src/setup/setup.ts[R159-168]

+  try {
+    const stats = fs.lstatSync(filePath)
+    if (!stats.isFile()) {
+      logger.warn({
+        message: `Skipping GitHub Actions environment file ${filePath}: not a regular file`,
+        prefix: process.cwd(),
+      })
+      return
+    }
+    const fd = fs.openSync(filePath, 'r+')
Evidence
The new code in both TS and Rust performs a file-type check and then opens the path later, which is
the classic TOCTOU pattern. The repo’s review guide explicitly flags TOCTOU/arbitrary file write
risks and treats env vars/paths as attacker-controlled inputs, making this a relevant
defense-in-depth hardening target for the changed code.

pnpm11/engine/pm/commands/src/setup/setup.ts[159-173]
pacquet/crates/cli/src/cli_args/setup.rs[152-160]
REVIEW_GUIDE.md[30-56]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
The code uses a metadata check (`lstatSync` / `symlink_metadata`) followed by a later `open`. Between those operations the path can change (TOCTOU), so the file opened may not be the file that was checked.

### Issue Context
REVIEW_GUIDE.md explicitly calls out TOCTOU and arbitrary file write risks, and recommends security-first handling of environment variables/paths as attacker-controlled inputs.

### Fix Focus Areas
- pnpm11/engine/pm/commands/src/setup/setup.ts[158-174]
- pacquet/crates/cli/src/cli_args/setup.rs[152-161]

### Suggested change
- **TypeScript:** open with `O_NOFOLLOW` where supported (e.g. `fs.openSync(filePath, fs.constants.O_WRONLY | fs.constants.O_APPEND | fs.constants.O_NOFOLLOW)` on Unix) and then `fstatSync(fd)` to verify it’s a regular file.
- **Rust:** on Unix, use `std::os::unix::fs::OpenOptionsExt::custom_flags(libc::O_NOFOLLOW)` with `append(true)` and then validate `file.metadata()?.file_type().is_file()`.
- Keep cross-platform behavior by conditionally applying `O_NOFOLLOW` only where available.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View more (4)
4. Warns on missing env files 🐞 Bug ◔ Observability
Description
In the TypeScript implementation, appendGitHubActionsEnvironmentFile() logs a warning for any fs
error, including ENOENT when $GITHUB_ENV/$GITHUB_PATH points to a non-existent file. This produces
avoidable warning noise in CI for a scenario the tests treat as “skip missing env files.”
Code

pnpm11/engine/pm/commands/src/setup/setup.ts[R158-180]

+function appendGitHubActionsEnvironmentFile (filePath: string, line: string): void {
+  try {
+    const stats = fs.lstatSync(filePath)
+    if (!stats.isFile()) {
+      logger.warn({
+        message: `Skipping GitHub Actions environment file ${filePath}: not a regular file`,
+        prefix: process.cwd(),
+      })
+      return
+    }
+    const fd = fs.openSync(filePath, 'r+')
+    try {
+      const { size } = fs.fstatSync(fd)
+      fs.writeSync(fd, `${line}\n`, size, 'utf8')
+    } finally {
+      fs.closeSync(fd)
+    }
+  } catch (err: unknown) {
+    logger.warn({
+      message: `Failed to write GitHub Actions environment file ${filePath}: ${err instanceof Error ? err.message : String(err)}`,
+      prefix: process.cwd(),
+    })
+  }
Evidence
The implementation warns for all errors while the test suite explicitly exercises the “missing
GitHub Actions env file” case and expects the file to remain uncreated/ignored; this code path will
still warn due to ENOENT from lstatSync().

pnpm11/engine/pm/commands/src/setup/setup.ts[158-181]
pnpm11/engine/pm/commands/test/setup/setup.test.ts[177-193]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`appendGitHubActionsEnvironmentFile()` currently warns on missing `$GITHUB_ENV`/`$GITHUB_PATH` files (ENOENT). This is noisy and inconsistent with the “skip missing env files” behavior tested in the suite.
### Issue Context
The helper wraps `lstatSync/openSync/fstatSync/writeSync` in one `try/catch` and warns for all thrown errors. A missing env/path file causes `lstatSync()` to throw ENOENT, which then becomes a warning.
### Fix Focus Areas
- pnpm11/engine/pm/commands/src/setup/setup.ts[158-181]
### Suggested fix
- In the `catch`, detect ENOENT (`err` is a NodeJS.ErrnoException and `err.code === 'ENOENT'`) and return silently.
- Optionally, apply the same ENOENT suppression for races where the file is removed between `lstatSync` and `openSync`.
- Keep warnings for other unexpected IO errors (permissions, EISDIR, etc.).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


5. Rust warning lacks failing path 🐞 Bug ◔ Observability
Description
In the Rust pacquet implementation, failures writing GitHub Actions env/path files are collapsed
into a single warning that only prints the raw io error, without identifying whether $GITHUB_ENV or
$GITHUB_PATH failed. This makes GitHub Actions persistence failures harder to debug.
Code

pacquet/crates/cli/src/cli_args/setup.rs[R112-118]

+    if let Err(err) =
+        write_github_actions_environment_files(pnpm_home_dir, bin_dir, github_env, github_path)
+    {
+        warn::<Reporter>(
+            prefix_dir,
+            &format!("Failed to write GitHub Actions environment files: {err}"),
+        );
Evidence
The Rust code warns once with only the io error string; the write helper performs separate writes
but the warning does not identify which target path caused the failure.

pacquet/crates/cli/src/cli_args/setup.rs[99-121]
pacquet/crates/cli/src/cli_args/setup.rs[134-150]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
When writing GitHub Actions environment files fails in pacquet, the warning message does not include which file path failed (GITHUB_ENV vs GITHUB_PATH). Since `std::io::Error` often doesn’t embed the path, the warning can be too vague to troubleshoot.
### Issue Context
`persist_github_actions_environment_to_files()` calls `write_github_actions_environment_files(...)` and warns once on error with `Failed to write GitHub Actions environment files: {err}`.
### Fix Focus Areas
- pacquet/crates/cli/src/cli_args/setup.rs[99-121]
- pacquet/crates/cli/src/cli_args/setup.rs[134-150]
### Suggested fix
- Emit per-file warnings that include the specific path, e.g.:
- if `github_env` is Some: call `append_existing_regular_file(...)` and on Err warn `Failed to append to GITHUB_ENV (<path>): <err>`.
- same for `github_path`.
- Continue attempting the second file even if the first fails, so partial persistence still happens.
- Keep the “do not create missing files / non-regular files are ignored” behavior unchanged.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


6. Env write aborts setup ✓ Resolved 🐞 Bug ☼ Reliability
Description
In both implementations, failures writing $GITHUB_ENV/$GITHUB_PATH are treated as fatal, so setup
can error after it already performed earlier side effects (rc edits and/or self-install + alias
scripts), leaving a partially-updated state. This is triggered by any unwritable/mis-set env file
path (permissions, directory path, etc.) once those env vars are set.
Code

pnpm11/engine/pm/commands/src/setup/setup.ts[R168-172]

   overwrite: opts.force,
   position: 'start',
 })
+    writeGitHubActionsEnvironmentFiles(opts.pnpmHomeDir, binDir)
 return renderSetupOutput(report)
Evidence
TS calls the new env/path append inside the main try block; any append failure throws and is
rethrown, failing the command. Rust performs self-install + alias scripts + PATH persistence, then
calls the new GitHub Actions writer which propagates IO errors via ?, also failing after side
effects.

pnpm11/engine/pm/commands/src/setup/setup.ts[141-183]
pacquet/crates/cli/src/cli_args/setup.rs[45-104]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`pnpm setup` (TS) and `pacquet setup` (Rust) currently fail the whole command if appending to GitHub Actions environment/path files fails, even though this persistence is an auxiliary side-effect. Because the write happens after other setup side effects, a write failure can leave a partially-applied setup state.
### Issue Context
GitHub Actions env/path files can be set in non-GHA contexts or be misconfigured/unwritable. In those cases we should not break `setup` after performing other changes; instead warn and continue.
### Fix Focus Areas
- pnpm11/engine/pm/commands/src/setup/setup.ts[141-183]
- pacquet/crates/cli/src/cli_args/setup.rs[45-104]
### Implementation notes
- Wrap the env/path file append operations in a try/catch (TS) / error-handling block (Rust).
- On failure, emit a warning (TS: logger.warn; Rust: Reporter warn event) including the underlying IO error, and continue returning the normal setup output.
- Consider writing the env/path files before doing irreversible side effects only if you still want to fail-fast; otherwise keep best-effort semantics.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


7. Env-file newline injection ✓ Resolved 🐞 Bug ⛨ Security
Description
writeGitHubActionsEnvironmentFiles() appends PNPM_HOME=${pnpmHomeDir} to $GITHUB_ENV without
rejecting/escaping \r/\n, so a crafted PNPM_HOME value can inject extra env records for later
GitHub Actions steps. This is reachable because pnpmHomeDir can come directly from the PNPM_HOME
environment variable without sanitization in the config reader.
Code

pnpm11/engine/pm/commands/src/setup/setup.ts[R141-149]

+function writeGitHubActionsEnvironmentFiles (pnpmHomeDir: string, binDir: string): void {
+  const githubEnv = process.env.GITHUB_ENV
+  const githubPath = process.env.GITHUB_PATH
+  if (githubEnv == null || githubPath == null) {
+    return
+  }
+  fs.appendFileSync(githubEnv, `PNPM_HOME=${pnpmHomeDir}\n`)
+  fs.appendFileSync(githubPath, `${binDir}\n`)
+}
Evidence
The new code writes pnpmHomeDir verbatim into $GITHUB_ENV, and pnpmHomeDir can be taken
verbatim from process.env.PNPM_HOME, which can include newline characters on POSIX systems; Rust
already treats these characters as unsafe for PNPM_HOME, highlighting the missing TS hardening.

pnpm11/engine/pm/commands/src/setup/setup.ts[141-149]
pnpm11/config/reader/src/dirs.ts[49-57]
pacquet/crates/cli/src/cli_args/setup/path_extender.rs[156-175]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`pnpm setup` persists `PNPM_HOME` to the GitHub Actions environment file using a line-oriented format (`KEY=value\n`). If `pnpmHomeDir` contains `\n`/`\r`, it will write additional lines into `$GITHUB_ENV`, effectively injecting extra environment variables for later steps.
## Issue Context
- `pnpmHomeDir` is sourced from the process environment (`PNPM_HOME`) in the config reader.
- Rust pacquet already hard-rejects newlines in `PNPM_HOME`, so TS should match that hardening to keep parity.
## Fix Focus Areas
- pnpm11/engine/pm/commands/src/setup/setup.ts[141-149]
- pnpm11/config/reader/src/dirs.ts[49-57]
### Suggested fix
- Before writing to `$GITHUB_ENV` / `$GITHUB_PATH`, reject `pnpmHomeDir` containing `\n` or `\r` (and ideally `\0`).
- Prefer to throw a `PnpmError` with a stable error code (or reuse an existing one if available) so CI failures are understandable.
- Consider applying the same validation to `binDir` (derived, but keeps the helper self-contained).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Informational

8. Requires both GitHub files ✓ Resolved 🐞 Bug ≡ Correctness
Description
The new persistence code returns early unless *both* GITHUB_ENV and GITHUB_PATH are set, so
PNPM_HOME (or the bin PATH) is not persisted even if one of the two GitHub Actions files is
available. This makes the behavior less robust in partially-provisioned CI environments or when one
of the variables is intentionally unset.
Code

pacquet/crates/cli/src/cli_args/setup.rs[R79-85]

+fn persist_github_actions_environment(pnpm_home_dir: &Path, bin_dir: &Path) -> miette::Result<()> {
+    let Some(github_env) = std::env::var_os("GITHUB_ENV").map(PathBuf::from) else {
+        return Ok(());
+    };
+    let Some(github_path) = std::env::var_os("GITHUB_PATH").map(PathBuf::from) else {
+        return Ok(());
+    };
Evidence
Both implementations explicitly check for both variables and return early when either is absent,
preventing writing to the other file even if it exists.

pnpm11/engine/pm/commands/src/setup/setup.ts[141-146]
pacquet/crates/cli/src/cli_args/setup.rs[79-85]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Persistence is currently gated on both `GITHUB_ENV` and `GITHUB_PATH` being present; if either is missing, nothing is written. This unnecessarily drops persistence when only one file is available.
### Issue Context
GitHub Actions typically sets both, but the code is also executed outside of Actions (or in custom runners), where only one might be set.
### Fix Focus Areas
- pnpm11/engine/pm/commands/src/setup/setup.ts[141-149]
- pacquet/crates/cli/src/cli_args/setup.rs[79-104]
### Implementation notes
- If `GITHUB_ENV` is set, append `PNPM_HOME=...` to it.
- If `GITHUB_PATH` is set, append the bin dir line to it.
- Treat each write independently (and ideally best-effort per the other finding).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


9. Trusts env file paths ✓ Resolved 🐞 Bug ⛨ Security
Description
The new GitHub Actions persistence code opens paths from GITHUB_ENV/GITHUB_PATH and appends to
them (creating files if missing) without verifying it’s actually running under GitHub Actions or
that the paths are expected/regular files. In attacker-controlled environments (or misconfigured
CI), this can cause unintended file creation/append to arbitrary locations accessible by the current
user.
Code

pacquet/crates/cli/src/cli_args/setup.rs[R79-103]

+fn persist_github_actions_environment(pnpm_home_dir: &Path, bin_dir: &Path) -> miette::Result<()> {
+    let Some(github_env) = std::env::var_os("GITHUB_ENV").map(PathBuf::from) else {
+        return Ok(());
+    };
+    let Some(github_path) = std::env::var_os("GITHUB_PATH").map(PathBuf::from) else {
+        return Ok(());
+    };
+    write_github_actions_environment_files(pnpm_home_dir, bin_dir, &github_env, &github_path)
+        .into_diagnostic()
+        .wrap_err("write GitHub Actions environment files")?;
+    Ok(())
+}
+
+fn write_github_actions_environment_files(
+    pnpm_home_dir: &Path,
+    bin_dir: &Path,
+    github_env: &Path,
+    github_path: &Path,
+) -> std::io::Result<()> {
+    let mut env_file = OpenOptions::new().create(true).append(true).open(github_env)?;
+    writeln!(env_file, "PNPM_HOME={}", pnpm_home_dir.display())?;
+
+    let mut path_file = OpenOptions::new().create(true).append(true).open(github_path)?;
+    writeln!(path_file, "{}", bin_dir.display())?;
+    Ok(())
Evidence
Both implementations take file paths from environment variables and append/create files directly,
with no runner gating or file-type validation; the repo’s review guide explicitly calls out env vars
and filesystem writes as attacker-controlled surfaces to scrutinize.

pacquet/crates/cli/src/cli_args/setup.rs[79-103]
pnpm11/engine/pm/commands/src/setup/setup.ts[141-149]
REVIEW_GUIDE.md[30-56]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The code uses `GITHUB_ENV` / `GITHUB_PATH` as file paths and appends to them with create-if-missing behavior. While GitHub Actions normally provides safe paths, this behavior can misfire outside Actions or if the environment variables are overridden, leading to unintended file creation/append.
## Issue Context
This PR intentionally adds GitHub Actions persistence; hardening should keep the feature but narrow it to the intended runner environment and reduce footguns.
## Fix Focus Areas
- pacquet/crates/cli/src/cli_args/setup.rs[79-103]
- pnpm11/engine/pm/commands/src/setup/setup.ts[141-149]
### Suggested fix
- Only write when `GITHUB_ACTIONS == "true"` (both Rust+TS) in addition to requiring `GITHUB_ENV`/`GITHUB_PATH`.
- Avoid `create(true)` / implicit create-on-append; require the files to already exist (if open fails with NotFound, just skip).
- Optionally (best-effort) check metadata to ensure the target is a regular file before writing (and skip if it’s a symlink).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 66cb11a

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 2

🧹 Nitpick comments (1)
pnpm11/engine/pm/commands/src/setup/setup.ts (1)

141-149: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use async fs APIs instead of appendFileSync.

The handler is already async; this helper uses synchronous fs.appendFileSync, blocking the event loop unnecessarily during setup.

As per coding guidelines, "Use async filesystem APIs and async/await; run independent work with Promise.all or Promise.any, and hoist invariant work out of loops."

♻️ Proposed fix
-function writeGitHubActionsEnvironmentFiles (pnpmHomeDir: string, binDir: string): void {
+async function writeGitHubActionsEnvironmentFiles (pnpmHomeDir: string, binDir: string): Promise<void> {
   const githubEnv = process.env.GITHUB_ENV
   const githubPath = process.env.GITHUB_PATH
   if (githubEnv == null || githubPath == null) {
     return
   }
-  fs.appendFileSync(githubEnv, `PNPM_HOME=${pnpmHomeDir}\n`)
-  fs.appendFileSync(githubPath, `${binDir}\n`)
+  await Promise.all([
+    fs.promises.appendFile(githubEnv, `PNPM_HOME=${pnpmHomeDir}\n`),
+    fs.promises.appendFile(githubPath, `${binDir}\n`),
+  ])
 }

And update the call site:

-    writeGitHubActionsEnvironmentFiles(opts.pnpmHomeDir, binDir)
+    await writeGitHubActionsEnvironmentFiles(opts.pnpmHomeDir, binDir)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pnpm11/engine/pm/commands/src/setup/setup.ts` around lines 141 - 149, The
helper writeGitHubActionsEnvironmentFiles is blocking the event loop by using
synchronous fs.appendFileSync even though the surrounding setup flow is async.
Update writeGitHubActionsEnvironmentFiles to use the async filesystem API with
await, and make sure the caller in setup uses the returned promise appropriately
so the environment file writes complete before continuing; keep the existing
GITHUB_ENV and GITHUB_PATH checks and preserve the same PNPM_HOME and binDir
content being written.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pacquet/crates/cli/src/cli_args/setup.rs`:
- Around line 79-90: `persist_github_actions_environment` should not read
`GITHUB_ENV` and `GITHUB_PATH` from `std::env` internally; pass those optional
paths in as parameters instead and let the caller fetch them once. Update the
`persist_github_actions_environment` flow in `setup.rs` to use the injected
values so the present/absent branches can be tested deterministically,
consistent with the existing `Host`-based DI pattern used by
`default_pnpm_home_dir::<Host>()` and `write_github_actions_environment_files`.

In `@pnpm11/engine/pm/commands/src/setup/setup.ts`:
- Around line 141-149: The writeGitHubActionsEnvironmentFiles helper writes
pnpmHomeDir and binDir directly into GITHUB_ENV and GITHUB_PATH, so reject or
escape any CR/LF characters before appending to avoid injecting extra entries.
Update the writeGitHubActionsEnvironmentFiles function to sanitize both values
before fs.appendFileSync, and add a regression test covering a
newline-containing pnpmHomeDir (and binDir if needed) to verify the unsafe input
is blocked.

---

Nitpick comments:
In `@pnpm11/engine/pm/commands/src/setup/setup.ts`:
- Around line 141-149: The helper writeGitHubActionsEnvironmentFiles is blocking
the event loop by using synchronous fs.appendFileSync even though the
surrounding setup flow is async. Update writeGitHubActionsEnvironmentFiles to
use the async filesystem API with await, and make sure the caller in setup uses
the returned promise appropriately so the environment file writes complete
before continuing; keep the existing GITHUB_ENV and GITHUB_PATH checks and
preserve the same PNPM_HOME and binDir content being written.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: c2bd4edb-2651-416a-83a9-d1d381a78201

📥 Commits

Reviewing files that changed from the base of the PR and between b789d81 and 66cb11a.

📒 Files selected for processing (5)
  • .changeset/pnpm-setup-github-actions.md
  • pacquet/crates/cli/src/cli_args/setup.rs
  • pacquet/crates/cli/src/cli_args/setup/tests.rs
  • pnpm11/engine/pm/commands/src/setup/setup.ts
  • pnpm11/engine/pm/commands/test/setup/setup.test.ts

@codecov-commenter

codecov-commenter commented Jul 7, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.54839% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.90%. Comparing base (3b1c181) to head (e97a233).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
...pm/crates/cli/src/cli_args/setup/gh_actions_env.rs 95.08% 6 Missing ⚠️
pnpm/crates/cli/src/cli_args/setup.rs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12841      +/-   ##
==========================================
- Coverage   86.91%   86.90%   -0.02%     
==========================================
  Files         528      529       +1     
  Lines       90605    90730     +125     
==========================================
+ Hits        78752    78848      +96     
- Misses      11853    11882      +29     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 83ba18e

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pacquet/crates/cli/src/cli_args/setup.rs`:
- Around line 99-150: The GitHub Actions environment file writes are currently
coupled in write_github_actions_environment_files, so a failure appending
GITHUB_ENV can prevent GITHUB_PATH from being written. Update
persist_github_actions_environment_to_files and
write_github_actions_environment_files so each target is attempted
independently, handling errors per append_existing_regular_file call instead of
chaining with ?; include the specific path or target name in each warning for
better context. You can use the existing warn::<Reporter> and
validate_github_actions_environment_file_value helpers to locate the affected
flow, and remove the outer single error check once per-file failures are
reported locally.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d14a3921-d084-4d96-bf5f-83aa181c1276

📥 Commits

Reviewing files that changed from the base of the PR and between 66cb11a and 83ba18e.

📒 Files selected for processing (4)
  • pacquet/crates/cli/src/cli_args/setup.rs
  • pacquet/crates/cli/src/cli_args/setup/tests.rs
  • pnpm11/engine/pm/commands/src/setup/setup.ts
  • pnpm11/engine/pm/commands/test/setup/setup.test.ts
📜 Review details
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use Standard Style with trailing commas in TypeScript code.
Prefer functions over classes in TypeScript code.
Declare functions after they are used in TypeScript code, relying on hoisting.
Keep TypeScript functions to no more than two or three arguments; use a single options object when more parameters are needed.
Use the import order fs/path standard libraries first, then external dependencies in alphabetical order, then relative imports.
Throw PnpmError for user-reachable errors; use plain Error for programmer errors, type-guard failures, and unreachable states. Catch only specific expected errors, never swallow errors, and include context such as offending paths in error messages.
Use existing project terminology in names, keep function names verb-driven, and avoid generic or invented names.
Reuse existing repository libraries and shared utilities instead of hand-rolling logic or adding duplicate dependencies.
Prefer plain string operations over custom regular expressions; use the existing parser-combinator pattern when structured parsing with backtracking is required.
Keep shared infrastructure dependencies at the appropriate level, with shared infrastructure such as the logger treated as a peer dependency.
Pass configurable values through @pnpm/config and command options, avoid hardcoding them, and have command handlers return data rather than printing directly when possible.
Use async filesystem APIs and async/await; run independent work with Promise.all or Promise.any, and hoist invariant work out of loops.

Files:

  • pnpm11/engine/pm/commands/test/setup/setup.test.ts
  • pnpm11/engine/pm/commands/src/setup/setup.ts
**/*.test.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

In Jest tests, do not use instanceof Error for caught error checks; use util.types.isNativeError() instead.

Files:

  • pnpm11/engine/pm/commands/test/setup/setup.test.ts
🧠 Learnings (13)
📚 Learning: 2026-05-14T09:04:00.133Z
Learnt from: zkochan
Repo: pnpm/pnpm PR: 11622
File: resolving/npm-resolver/test/publishedBy.test.ts:350-354
Timestamp: 2026-05-14T09:04:00.133Z
Learning: In the pnpm/pnpm repository, ESLint is the authoritative style linter. Do not raise review findings for missing trailing commas in multiline function calls (e.g., `fs.writeFileSync(...)`) when this repo’s ESLint configuration does not report them and lint passes. Prefer deferring to the ESLint results for this specific trailing-comma rule rather than enforcing it manually in code review.

Applied to files:

  • pnpm11/engine/pm/commands/test/setup/setup.test.ts
  • pnpm11/engine/pm/commands/src/setup/setup.ts
📚 Learning: 2026-06-05T13:47:05.929Z
Learnt from: vsumner
Repo: pnpm/pnpm PR: 12190
File: installing/deps-installer/test/install/frozenStore.ts:2-17
Timestamp: 2026-06-05T13:47:05.929Z
Learning: In the pnpm/pnpm repository, the shared Jest preset keeps `injectGlobals` at its default (`true`), so `test` and `expect` are available as Jest globals. Therefore, reviewers should not flag (or treat as TypeScript/compilation errors) missing `import { test, expect } from 'jest/globals'` when a test file uses `test`/`expect` without importing them. Importing from `jest/globals` may still be used for consistency with sibling files, but it is not required for execution in this repo unless a Jest preset is explicitly configured with `injectGlobals: false`.

Applied to files:

  • pnpm11/engine/pm/commands/test/setup/setup.test.ts
📚 Learning: 2026-06-05T13:47:26.046Z
Learnt from: vsumner
Repo: pnpm/pnpm PR: 12190
File: installing/deps-installer/src/install/index.ts:2337-2343
Timestamp: 2026-06-05T13:47:26.046Z
Learning: In the pnpm/pnpm codebase, `PnpmError` automatically prefixes `err.code` with `ERR_PNPM_` when you pass a code that does not already start with `ERR_PNPM_` (it normalizes `this.code` via `code.startsWith('ERR_PNPM_') ? code : `ERR_PNPM_${code}``). Therefore, during code review you should NOT flag `new PnpmError(...)` call sites for passing a bare error code (e.g., `new PnpmError('FROZEN_STORE_INCOMPATIBLE_WITH_PNPR', ...)`); the resulting `err.code` will still be `ERR_PNPM_FROZEN_STORE_INCOMPATIBLE_WITH_PNPR`.

Applied to files:

  • pnpm11/engine/pm/commands/test/setup/setup.test.ts
  • pnpm11/engine/pm/commands/src/setup/setup.ts
📚 Learning: 2026-05-20T19:40:55.051Z
Learnt from: zkochan
Repo: pnpm/pnpm PR: 11774
File: pacquet/crates/resolving-deps-resolver/src/resolve_peers.rs:0-0
Timestamp: 2026-05-20T19:40:55.051Z
Learning: In the pacquet Rust code, ensure the semver implementation uses the `node-semver` crate (not `nodejs-semver`). `node-semver`’s public API does not include a `satisfies_with_prerelease`-style method; prerelease-tolerant matching should be implemented inline by first calling `Range::satisfies`, and when it rejects a prerelease version, retry matching against a stripped `MAJOR.MINOR.PATCH` base of the prerelease version.

Applied to files:

  • pacquet/crates/cli/src/cli_args/setup/tests.rs
  • pacquet/crates/cli/src/cli_args/setup.rs
📚 Learning: 2026-05-22T00:08:44.646Z
Learnt from: zkochan
Repo: pnpm/pnpm PR: 11837
File: pacquet/crates/resolving-npm-resolver/src/pick_package.rs:33-51
Timestamp: 2026-05-22T00:08:44.646Z
Learning: In the pnpm/pnpm repo’s pacquet Rust crates, do not flag Unicode ellipsis characters (U+2026, `…`) in Rust doc comments (`///` / `/** */`) as a lint violation. The pacquet crate’s `dylint.toml` only enables `perfectionist::derive_ordering`, and the Dylint `unicode-ellipsis` rule is not enabled for this project—so `…` in doc comments is an intentional, repo-consistent style.

Applied to files:

  • pacquet/crates/cli/src/cli_args/setup/tests.rs
  • pacquet/crates/cli/src/cli_args/setup.rs
📚 Learning: 2026-05-20T23:07:58.444Z
Learnt from: zkochan
Repo: pnpm/pnpm PR: 11784
File: pacquet/crates/resolving-deps-resolver/src/hoist_peers.rs:120-133
Timestamp: 2026-05-20T23:07:58.444Z
Learning: When reviewing code in this pacquet Rust port, follow the upstream pnpm compatibility rule: only match pnpm’s behavior exactly. Do not propose review changes that intentionally deviate from pnpm’s documented/observed behavior, even if pnpm appears buggy. If you identify a real bug in pnpm behavior, the review should prioritize fixing it upstream in pnpm first, and avoid implementing a pnpm-behavior workaround here unless the same fix has already landed upstream.

Applied to files:

  • pacquet/crates/cli/src/cli_args/setup/tests.rs
  • pacquet/crates/cli/src/cli_args/setup.rs
📚 Learning: 2026-06-06T18:58:37.156Z
Learnt from: zkochan
Repo: pnpm/pnpm PR: 12243
File: pacquet/crates/package-manager/src/install_package_by_snapshot.rs:319-322
Timestamp: 2026-06-06T18:58:37.156Z
Learning: When reviewing Rust code, do not assume `matches!(expr, Pattern(_))` will move out of `expr` if `Pattern(_)` contains no by-value bindings. `matches!` desugars to a `match` that auto-borrows the scrutinee for discrimination, so even if `expr` is a non-`Copy` value behind a shared reference (e.g., `&T`), the macro should not move-out of the borrowed data purely due to `matches!`. Treat `matches!(&expr, Pattern(_))` as a readability/clarity improvement, not a correctness requirement. Only flag potential move-out-of-borrow risks when the pattern includes by-value bindings that would require moving the matched value.

Applied to files:

  • pacquet/crates/cli/src/cli_args/setup/tests.rs
  • pacquet/crates/cli/src/cli_args/setup.rs
📚 Learning: 2026-06-12T20:41:57.558Z
Learnt from: zkochan
Repo: pnpm/pnpm PR: 12364
File: pacquet/crates/package-manager/src/install/tests.rs:5717-5717
Timestamp: 2026-06-12T20:41:57.558Z
Learning: In the pnpm/pnpm Rust workspace (toolchain Rust 1.95.0), keep using `std::time::Duration::from_mins(...)` and `std::time::Duration::from_hours(...)` as-is. Do not flag these as invalid or suggest replacing them with `Duration::from_secs(...)`, because Clippy’s `clippy::duration_suboptimal_units` lint is denied by `-D warnings` in CI, and changing to seconds may trigger CI failures.

Applied to files:

  • pacquet/crates/cli/src/cli_args/setup/tests.rs
  • pacquet/crates/cli/src/cli_args/setup.rs
📚 Learning: 2026-06-29T10:07:32.128Z
Learnt from: KSXGitHub
Repo: pnpm/pnpm PR: 12719
File: pacquet/crates/cli/tests/update.rs:56-56
Timestamp: 2026-06-29T10:07:32.128Z
Learning: When reviewing Rust code, do not flag `format!`, `write!`, or `writeln!` calls as having “missing format arguments” if the format string is a raw string literal (e.g., `r#"...{name}..."#`, `br#"...{spec}..."#`) that uses Rust’s captured-format-argument syntax (`{name}`, `{spec}`, etc.). Raw string literals still support captured-format placeholders, so the code is valid as long as those captured names correspond to in-scope variables and compiles.

Applied to files:

  • pacquet/crates/cli/src/cli_args/setup/tests.rs
  • pacquet/crates/cli/src/cli_args/setup.rs
📚 Learning: 2026-06-19T14:23:52.915Z
Learnt from: KSXGitHub
Repo: pnpm/pnpm PR: 12510
File: pacquet/crates/real-hoist/src/tests.rs:1098-1098
Timestamp: 2026-06-19T14:23:52.915Z
Learning: In the pnpm/pnpm Pacquet Rust codebase, treat `dbg!` calls that appear immediately before an `assert!` (but not `assert_eq!`)—especially when checking complex values like `HashMap<..., VecDeque<...>>`—as intentional, per `CODE_STYLE_GUIDE.md` ("When or when not to log during tests?"). Do not flag these `dbg!` statements as debugging noise or recommend removing them. This is meant to ensure that if the test fails, the actual logged value is visible; `just test` runs tests via `cargo nextest run`, which keeps output from passing tests and only surfaces it on failures.

Applied to files:

  • pacquet/crates/cli/src/cli_args/setup/tests.rs
📚 Learning: 2026-06-24T14:12:19.207Z
Learnt from: exidniy
Repo: pnpm/pnpm PR: 12632
File: pacquet/crates/cli/src/cli_args/root.rs:29-31
Timestamp: 2026-06-24T14:12:19.207Z
Learning: In the pacquet Rust CLI, do NOT flag “not supported yet” / unsupported-flag refusals (e.g., update/outdated/root with flags like --global/--workspace/--recursive that are known to be accepted upstream) just because they use raw `miette::miette!(...)` instead of a dedicated `pacquet-diagnostics` error type. There is currently no corresponding “not supported yet” diagnostic in `pacquet-diagnostics` and there is no pnpm-defined error code for these cases, so the established, consistent pattern across all unported-feature refusals is to use `miette::miette!(...)`. If this behavior ever needs to change, it should be done as a cross-command refactor (introducing/using a diagnostics type across all such refusals), not handled piecemeal per command.

Applied to files:

  • pacquet/crates/cli/src/cli_args/setup/tests.rs
  • pacquet/crates/cli/src/cli_args/setup.rs
📚 Learning: 2026-06-25T16:51:27.373Z
Learnt from: zkochan
Repo: pnpm/pnpm PR: 12567
File: pacquet/crates/cli/src/cli_args/pack.rs:111-151
Timestamp: 2026-06-25T16:51:27.373Z
Learning: In the pacquet CLI, `Config::filter` / `Config::filter_prod` may exist for parity but are not (yet) applied to recursive commands. When reviewing selector handling for `run -r`, `exec -r`, and `pack -r`, do not ask for a `pack -r`-only fix. Any support for `--filter` / `--filter-prod` must be implemented as a cross-cutting change in the shared recursive selection path that all `*-r` commands use (the path that iterates workspace projects), so selectors are applied consistently.

Applied to files:

  • pacquet/crates/cli/src/cli_args/setup/tests.rs
  • pacquet/crates/cli/src/cli_args/setup.rs
📚 Learning: 2026-06-26T01:25:59.891Z
Learnt from: spencer17x
Repo: pnpm/pnpm PR: 12661
File: pacquet/crates/cli/src/cli_args/completion.rs:51-65
Timestamp: 2026-06-26T01:25:59.891Z
Learning: In the pnpm/pnpm Pacquet CLI, keep command-specific, user-facing diagnostic enums in their local module under `pacquet/crates/cli/src/cli_args/` (e.g., `pacquet/crates/cli/src/cli_args/*`) rather than moving them into a shared diagnostics crate. When reviewing changes, only suggest moving/introducing a shared diagnostics API (e.g., `pacquet-diagnostics`) if the enum is reused across multiple commands or there is an established shared API pattern that provides a real boundary and avoids duplication.

Applied to files:

  • pacquet/crates/cli/src/cli_args/setup.rs
🪛 ast-grep (0.44.1)
pnpm11/engine/pm/commands/src/setup/setup.ts

[warning] Importing child_process exposes a command-execution surface; ensure any command/argument built from input is validated, and prefer execFile/spawn with an argument array over exec.
Context: import { spawnSync } from 'node:child_process'
Note: [CWE-78] Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').

(detect-child-process-typescript)


[warning] Importing child_process exposes a command-execution surface; ensure any command/argument built from input is validated, and prefer execFile/spawn with an argument array over exec.
Context: import { spawnSync } from 'node:child_process'
Note: [CWE-78] Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').

(detect-child-process-typescript)


[warning] Importing child_process exposes a command-execution surface; ensure any command/argument built from input is validated, and prefer execFile/spawn with an argument array over exec.
Context: import { spawnSync } from 'node:child_process'
Note: [CWE-78] Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').

(detect-child-process-typescript)

🔇 Additional comments (5)
pacquet/crates/cli/src/cli_args/setup.rs (2)

152-161: LGTM!

Also applies to: 17-23, 299-314


46-78: 🔒 Security & Privacy

Validate GitHub Actions env-file values before setup side effects.
The GitHub Actions file-value check should run before install_cli_globally, create_alias_scripts, and add_dir_to_env_path; otherwise a malformed PNPM_HOME may already mutate the system before setup aborts.

pnpm11/engine/pm/commands/src/setup/setup.ts (1)

142-230: LGTM!

pnpm11/engine/pm/commands/test/setup/setup.test.ts (1)

41-64: LGTM!

Also applies to: 106-212

pacquet/crates/cli/src/cli_args/setup/tests.rs (1)

79-198: LGTM!

Comment thread pnpm/crates/cli/src/cli_args/setup.rs Resolved
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 83ba18e

@github-actions

github-actions Bot commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

Commit: e97a233f4df9

Each scenario reports direct installs and pnpr installs. Bencher consumes pacquet@HEAD and pnpr@HEAD.

The tables below show mean ± σ; Bencher thresholds on the minimum latency, which is far less perturbed by shared-runner contention (noise only adds time).

Scenario: Isolated linker: fresh restore, cold cache + cold store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.545 ± 0.138 2.347 2.746 1.69 ± 0.18
pacquet@main 2.504 ± 0.145 2.352 2.755 1.66 ± 0.18
pnpr@HEAD 1.638 ± 0.105 1.483 1.761 1.09 ± 0.12
pnpr@main 1.507 ± 0.141 1.348 1.725 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.5452472962600003,
      "stddev": 0.1381529417816067,
      "median": 2.53932990156,
      "user": 1.6642485399999998,
      "system": 1.3062119600000002,
      "min": 2.34732413856,
      "max": 2.74592571856,
      "times": [
        2.61693803756,
        2.72001229056,
        2.42372463756,
        2.55322686956,
        2.38081136956,
        2.74592571856,
        2.34732413856,
        2.6507942835600002,
        2.52543293356,
        2.48828268356
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.5037939918600003,
      "stddev": 0.14506973357816794,
      "median": 2.4396444980600003,
      "user": 1.6556515400000003,
      "system": 1.28938676,
      "min": 2.3517104745600004,
      "max": 2.75496695156,
      "times": [
        2.37258617056,
        2.42999794656,
        2.5634775635600002,
        2.3517104745600004,
        2.4429181895600003,
        2.75496695156,
        2.4363708065600003,
        2.67723314356,
        2.6433228525600003,
        2.36535581956
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.6379832720600003,
      "stddev": 0.10487696912298436,
      "median": 1.6436513700600002,
      "user": 1.1890347399999999,
      "system": 1.15512436,
      "min": 1.48346813256,
      "max": 1.76106511956,
      "times": [
        1.60685181856,
        1.7017341835600002,
        1.56016287456,
        1.75973452256,
        1.76106511956,
        1.48346813256,
        1.6804509215600003,
        1.5828060495600003,
        1.74153484656,
        1.5020242515600002
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.50690199076,
      "stddev": 0.1410350059821617,
      "median": 1.5005615310600002,
      "user": 1.23091544,
      "system": 1.1027757599999999,
      "min": 1.34826985256,
      "max": 1.72537223556,
      "times": [
        1.3716500745600002,
        1.5491516285600002,
        1.34826985256,
        1.68714572856,
        1.72537223556,
        1.3840859545600002,
        1.3631759225600002,
        1.51229348756,
        1.6390454485600001,
        1.4888295745600002
      ]
    }
  ]
}

Scenario: Isolated linker: fresh restore, hot cache + hot store

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 248.1 ± 4.7 243.7 258.1 1.00
pacquet@main 250.1 ± 4.1 245.0 258.1 1.01 ± 0.03
pnpr@HEAD 268.9 ± 8.6 259.0 281.5 1.08 ± 0.04
pnpr@main 271.7 ± 12.8 262.9 306.5 1.10 ± 0.06
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.24805495752000004,
      "stddev": 0.004728795102761315,
      "median": 0.24595524292000004,
      "user": 0.20583456,
      "system": 0.49112132,
      "min": 0.24368291492000002,
      "max": 0.25806130192000004,
      "times": [
        0.25279799792,
        0.24530808492000003,
        0.24574313392000002,
        0.24368291492000002,
        0.24616735192000003,
        0.25248397192,
        0.24506353992000002,
        0.24677084692,
        0.25806130192000004,
        0.24447043092
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.25005125142000006,
      "stddev": 0.004113956469522122,
      "median": 0.24925801542000003,
      "user": 0.19617055999999997,
      "system": 0.50285622,
      "min": 0.24502084692000003,
      "max": 0.25809794192,
      "times": [
        0.24867588192,
        0.24955321692000004,
        0.24502084692000003,
        0.24554089292000003,
        0.25253649892,
        0.24896281392000003,
        0.25212108192000005,
        0.25809794192,
        0.25375228692,
        0.24625105192000002
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.26888380252000005,
      "stddev": 0.008630397116987421,
      "median": 0.26944958242000006,
      "user": 0.20328706,
      "system": 0.5167447199999999,
      "min": 0.25903230792000004,
      "max": 0.28145892192000005,
      "times": [
        0.26840093392000003,
        0.26031662392000005,
        0.28145892192000005,
        0.26141502292,
        0.27256692592000004,
        0.25903230792000004,
        0.27607536392000004,
        0.27995348192,
        0.25912021192,
        0.27049823092
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.27165268722,
      "stddev": 0.012772524269681234,
      "median": 0.26818747092,
      "user": 0.21434065999999996,
      "system": 0.5117119199999999,
      "min": 0.26289996392000003,
      "max": 0.30653212192,
      "times": [
        0.27039963992000005,
        0.26303918192000003,
        0.27240909392,
        0.26289996392000003,
        0.26781118892,
        0.30653212192,
        0.26645091392000003,
        0.26500153192000003,
        0.27341948292,
        0.26856375292
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, cold cache + cold store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.739 ± 0.018 2.710 2.767 1.75 ± 0.16
pacquet@main 2.744 ± 0.015 2.709 2.765 1.75 ± 0.16
pnpr@HEAD 1.565 ± 0.142 1.423 1.791 1.00
pnpr@main 1.605 ± 0.127 1.460 1.856 1.03 ± 0.12
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.7391186153200002,
      "stddev": 0.017757428683962056,
      "median": 2.73456009472,
      "user": 1.8411629599999995,
      "system": 1.33051684,
      "min": 2.70997846572,
      "max": 2.76700380872,
      "times": [
        2.73669422972,
        2.76700380872,
        2.75920930472,
        2.70997846572,
        2.72382872372,
        2.7311028997199998,
        2.72801972672,
        2.74752535272,
        2.73242595972,
        2.75539768172
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.7439596462199995,
      "stddev": 0.01480992022637871,
      "median": 2.74435356622,
      "user": 1.8129415599999998,
      "system": 1.3250338400000001,
      "min": 2.70914262972,
      "max": 2.76501953072,
      "times": [
        2.74235993372,
        2.73717099772,
        2.7577481007199998,
        2.74242462572,
        2.74628250672,
        2.74139198472,
        2.76501953072,
        2.75165211272,
        2.74640403972,
        2.70914262972
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.56547841772,
      "stddev": 0.14202166973622815,
      "median": 1.50857099772,
      "user": 1.1655402599999998,
      "system": 1.1898850400000003,
      "min": 1.42278317172,
      "max": 1.79063376372,
      "times": [
        1.53999215172,
        1.4463479397199999,
        1.60354829672,
        1.47714984372,
        1.79063376372,
        1.46335276772,
        1.43603247372,
        1.42278317172,
        1.7334562927200001,
        1.74148747572
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.60476110002,
      "stddev": 0.12656159102626105,
      "median": 1.54882677772,
      "user": 1.1870868599999997,
      "system": 1.15431924,
      "min": 1.46026569772,
      "max": 1.8561791217199999,
      "times": [
        1.68413036872,
        1.51796529472,
        1.8561791217199999,
        1.77334230572,
        1.55232657472,
        1.46026569772,
        1.59853721172,
        1.51859455072,
        1.54532698072,
        1.54094289372
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, hot cache + hot store

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 586.1 ± 10.5 569.4 606.4 1.97 ± 0.06
pacquet@main 568.3 ± 9.5 557.9 584.7 1.91 ± 0.06
pnpr@HEAD 299.5 ± 4.5 292.2 305.6 1.01 ± 0.03
pnpr@main 297.9 ± 7.4 287.6 308.0 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.5861045545000001,
      "stddev": 0.010543016839855998,
      "median": 0.5845727542000001,
      "user": 0.71023542,
      "system": 0.69383392,
      "min": 0.5693774052,
      "max": 0.6063940822,
      "times": [
        0.5693774052,
        0.5890081072000001,
        0.5980771792,
        0.5851721702,
        0.5898196422,
        0.5839733382000001,
        0.6063940822,
        0.5803795402,
        0.5766061092,
        0.5822379712000001
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.5683258905,
      "stddev": 0.009508685255057815,
      "median": 0.5676300042,
      "user": 0.6828245200000002,
      "system": 0.67389022,
      "min": 0.5579255762,
      "max": 0.5847281182,
      "times": [
        0.5798366572,
        0.5622049922000001,
        0.5684972102,
        0.5580172732,
        0.5773086662000001,
        0.5847281182,
        0.5680628662,
        0.5671971422000001,
        0.5594804032,
        0.5579255762
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.29951107200000004,
      "stddev": 0.004491078343829157,
      "median": 0.29970922870000005,
      "user": 0.20218482,
      "system": 0.5015925199999999,
      "min": 0.2921531102,
      "max": 0.3056466862,
      "times": [
        0.3024168942,
        0.2921531102,
        0.29309557220000004,
        0.3024044992,
        0.29819508520000004,
        0.29769196020000005,
        0.3056466862,
        0.3041812622,
        0.2981022782,
        0.3012233722
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.29789250030000003,
      "stddev": 0.007419061331630259,
      "median": 0.29646052920000004,
      "user": 0.20160342,
      "system": 0.48851132,
      "min": 0.2875657452,
      "max": 0.3080405162,
      "times": [
        0.29368278020000005,
        0.3039776932,
        0.2875657452,
        0.3063225242,
        0.29365444820000003,
        0.3080405162,
        0.2890814762,
        0.29923827820000004,
        0.2931448682,
        0.3042166732
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, cold cache + hot store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.899 ± 0.013 1.880 1.915 6.33 ± 0.16
pacquet@main 1.885 ± 0.008 1.871 1.901 6.29 ± 0.16
pnpr@HEAD 0.300 ± 0.004 0.292 0.306 1.00 ± 0.03
pnpr@main 0.300 ± 0.007 0.287 0.313 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.8988457308800002,
      "stddev": 0.012505208200999962,
      "median": 1.89931356388,
      "user": 0.9363474599999998,
      "system": 0.76304266,
      "min": 1.88047236388,
      "max": 1.91469328088,
      "times": [
        1.91234981488,
        1.91151046288,
        1.91469328088,
        1.90694960888,
        1.8842835228800001,
        1.88047236388,
        1.90138954788,
        1.8862514618800001,
        1.89331966488,
        1.89723757988
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 1.8847912697799998,
      "stddev": 0.008467469187868356,
      "median": 1.88500126638,
      "user": 0.90576536,
      "system": 0.75912696,
      "min": 1.87056907288,
      "max": 1.9005212788799999,
      "times": [
        1.87737595188,
        1.88747510688,
        1.88221070888,
        1.88421211588,
        1.8916921818799999,
        1.88579041688,
        1.87056907288,
        1.8902225428800001,
        1.87784332088,
        1.9005212788799999
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.29989449138,
      "stddev": 0.004431673086744233,
      "median": 0.29939858188,
      "user": 0.18404095999999998,
      "system": 0.51654346,
      "min": 0.29207784888000005,
      "max": 0.30565062488000005,
      "times": [
        0.30556794288000005,
        0.29924205488000005,
        0.30416355888,
        0.30063551588000004,
        0.29456920888000004,
        0.29878792888000005,
        0.29207784888000005,
        0.30565062488000005,
        0.29869512088000005,
        0.29955510888000003
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.29982735198000005,
      "stddev": 0.007482308369721885,
      "median": 0.30013419488000004,
      "user": 0.19229636,
      "system": 0.49168925999999996,
      "min": 0.28740882688,
      "max": 0.31312843288000003,
      "times": [
        0.30321840088,
        0.30111350288000005,
        0.29839187788000004,
        0.28740882688,
        0.31312843288000003,
        0.29577224488000003,
        0.29111771788,
        0.29958971288,
        0.30067867688000005,
        0.30785412588000005
      ]
    }
  ]
}

Scenario: Isolated linker: fresh resolve, hot cache, offline

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 361.1 ± 8.1 351.1 377.5 4.10 ± 0.15
pacquet@main 359.3 ± 5.6 352.2 370.9 4.08 ± 0.13
pnpr@HEAD 89.2 ± 3.7 84.8 98.5 1.01 ± 0.05
pnpr@main 88.1 ± 2.5 84.6 95.1 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.36106753736,
      "stddev": 0.008128778435081653,
      "median": 0.36071022556000004,
      "user": 0.34760724,
      "system": 0.07331557999999999,
      "min": 0.35114559906000004,
      "max": 0.37753035606,
      "times": [
        0.37753035606,
        0.36115731006,
        0.35405982206000003,
        0.37177145606,
        0.35833532706000004,
        0.36042886506000005,
        0.35375531206000005,
        0.36149974006,
        0.35114559906000004,
        0.36099158606000004
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.35933278806,
      "stddev": 0.005608318403240833,
      "median": 0.35841433006,
      "user": 0.34481404,
      "system": 0.07261418,
      "min": 0.35215204506000003,
      "max": 0.37092123806000005,
      "times": [
        0.37092123806000005,
        0.35535915706000004,
        0.35530221906000004,
        0.36284636906,
        0.35215204506000003,
        0.36448143206000005,
        0.35923642406,
        0.35471143606000005,
        0.36072532406,
        0.35759223606
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.08915781531806456,
      "stddev": 0.003738288341671636,
      "median": 0.08731524606000002,
      "user": 0.020965672258064515,
      "system": 0.011265557419354841,
      "min": 0.08482187506000001,
      "max": 0.09853798906000001,
      "times": [
        0.09122683306000001,
        0.08496726506,
        0.08682867206000001,
        0.08665120606000001,
        0.08731524606000002,
        0.09853798906000001,
        0.08826288506000002,
        0.08988478606000001,
        0.08482187506000001,
        0.09651026506000002,
        0.08661316906000001,
        0.08720679206000001,
        0.08763570406000001,
        0.08654091706000001,
        0.08988031206000001,
        0.08708433306000002,
        0.09507070706000001,
        0.09331530806000002,
        0.09265653206000002,
        0.08551427506,
        0.08630830706,
        0.08651657106,
        0.08714209006000001,
        0.08610276006,
        0.08610490206000002,
        0.08762309106,
        0.08623317206000002,
        0.09598895406,
        0.09276567406000001,
        0.09183384606000002,
        0.09074783506000002
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.08809923544709677,
      "stddev": 0.002461579597430732,
      "median": 0.08722836706,
      "user": 0.020578898064516134,
      "system": 0.010484984516129033,
      "min": 0.08456928406000001,
      "max": 0.09507628706000001,
      "times": [
        0.08906311406000002,
        0.08632355306000002,
        0.08686491806000002,
        0.08558217506000002,
        0.09507628706000001,
        0.08846182606000001,
        0.08619166806000002,
        0.08677363106000001,
        0.08628626406,
        0.08835731106000001,
        0.09012241406000002,
        0.08626324406000001,
        0.08837410706000001,
        0.08477187106000002,
        0.08665014106000002,
        0.08653450706000002,
        0.09056043406000001,
        0.08649721306000001,
        0.08456928406000001,
        0.08709344006000001,
        0.09117585606000002,
        0.08966031106000001,
        0.08826428606000002,
        0.08606812206000002,
        0.08822779606000002,
        0.08501600206000001,
        0.09158171006000002,
        0.09152500606000001,
        0.09145836406,
        0.08722836706,
        0.09045307506000001
      ]
    }
  ]
}

Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.454 ± 0.049 4.404 4.583 1.26 ± 0.04
pacquet@main 4.609 ± 0.191 4.415 4.857 1.30 ± 0.07
pnpr@HEAD 3.625 ± 0.156 3.458 3.837 1.02 ± 0.05
pnpr@main 3.538 ± 0.104 3.451 3.813 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.45443662478,
      "stddev": 0.04929239172081618,
      "median": 4.4418995602799995,
      "user": 1.82180824,
      "system": 1.4044280599999999,
      "min": 4.4041335647799995,
      "max": 4.58266880678,
      "times": [
        4.4360037627799995,
        4.44730674478,
        4.58266880678,
        4.47630573178,
        4.43566101778,
        4.43649237578,
        4.417986390779999,
        4.4041335647799995,
        4.45715958078,
        4.4506482717799996
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.608640711880001,
      "stddev": 0.19123398168890793,
      "median": 4.57593179528,
      "user": 1.8047602399999998,
      "system": 1.41481096,
      "min": 4.41498062978,
      "max": 4.85722074078,
      "times": [
        4.41498062978,
        4.44499788978,
        4.70686570078,
        4.85722074078,
        4.80784014378,
        4.43584254878,
        4.41819048778,
        4.7958670437799995,
        4.44033561378,
        4.76426631978
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.62536518728,
      "stddev": 0.15566256545089077,
      "median": 3.57321877528,
      "user": 1.29658834,
      "system": 1.24751136,
      "min": 3.4583644047799997,
      "max": 3.83683211878,
      "times": [
        3.52563186478,
        3.83683211878,
        3.46240733278,
        3.4676857977799997,
        3.58851641978,
        3.81524100578,
        3.76939165078,
        3.55792113078,
        3.77166014678,
        3.4583644047799997
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 3.53785106048,
      "stddev": 0.10357954585339109,
      "median": 3.5154921867799995,
      "user": 1.32835034,
      "system": 1.2274233599999997,
      "min": 3.45051130378,
      "max": 3.81263488478,
      "times": [
        3.54275530978,
        3.47576619278,
        3.45680024678,
        3.5248099477799997,
        3.5019197477799997,
        3.50617442578,
        3.45051130378,
        3.81263488478,
        3.55059964478,
        3.5565389007799997
      ]
    }
  ]
}

@github-actions

github-actions Bot commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/12841
Testbedpacquet
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
milliseconds (ms)
(Result Δ%)
Upper Boundary
milliseconds (ms)
(Limit %)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
🚷 view threshold
2,727.68 ms
(-23.45%)Baseline: 3,563.40 ms
4,276.08 ms
(63.79%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
1,895.53 ms
(-25.07%)Baseline: 2,529.84 ms
3,035.81 ms
(62.44%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
632.32 ms
(-39.36%)Baseline: 1,042.80 ms
1,251.37 ms
(50.53%)
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
🚷 view threshold
368.81 ms
(-29.46%)Baseline: 522.86 ms
627.43 ms
(58.78%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
2,639.43 ms
(-18.21%)Baseline: 3,226.93 ms
3,872.32 ms
(68.16%)
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
🚷 view threshold
4,601.16 ms
(-21.46%)Baseline: 5,858.62 ms
7,030.34 ms
(65.45%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
233.68 ms
(-48.64%)Baseline: 455.01 ms
546.01 ms
(42.80%)
🐰 View full continuous benchmarking report in Bencher

@github-actions

github-actions Bot commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/12841
Testbedpnpr

⚠️ WARNING: No Threshold found!

Without a Threshold, no Alerts will ever be generated.

Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the --ci-only-thresholds flag.

Click to view all benchmark results
BenchmarkLatencymilliseconds (ms)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
1,651.63 ms
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
255.44 ms
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
263.51 ms
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
⚠️ NO THRESHOLD
83.83 ms
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
1,582.86 ms
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
⚠️ NO THRESHOLD
3,531.15 ms
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
239.74 ms
🐰 View full continuous benchmarking report in Bencher

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
pacquet/crates/cli/src/cli_args/setup/tests.rs (1)

211-212: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider logging the captured warning before the non-scalar assertions.

assert!(warnings[0].contains(...)) isn't a simple scalar equality check, so per the style guide these benefit from an eprintln!/dbg! of warnings[0] beforehand to aid failure diagnosis.

As per path instructions (pacquet/CODE_STYLE_GUIDE.md): "when assertions aren't simple scalar equality, log before asserting (use eprintln!/dbg! patterns)."

🔧 Suggested addition
     let warnings = WARNINGS.lock().expect("lock warnings");
     assert_eq!(warnings.len(), 1);
+    eprintln!("captured warning: {}", warnings[0]);
     assert!(warnings[0].contains("GITHUB_ENV"));
     assert!(warnings[0].contains(&github_env.display().to_string()));
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pacquet/crates/cli/src/cli_args/setup/tests.rs` around lines 211 - 212, The
warning checks in the setup tests use contains-based assertions on warnings[0],
so add a debug log of the captured warning before those assertions to make
failures easier to diagnose. Update the relevant test in setup/tests.rs near the
warnings[0] checks by printing or dbg-ing warnings[0] first, then keep the
existing contains assertions against GITHUB_ENV and the github_env path.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pacquet/crates/cli/src/cli_args/setup/tests.rs`:
- Around line 172-213: The test in
github_actions_environment_file_failures_do_not_skip_other_targets relies on
make_file_readonly, which can fail to trigger on root-run GitHub Actions runners
because permission bits alone may still allow writes. Replace that setup with a
deterministic root-agnostic failure mechanism for the GITHUB_ENV path in
persist_github_actions_environment_to_files, while keeping the GITHUB_PATH file
writable so the test still verifies other targets continue processing and the
warning is recorded.

---

Nitpick comments:
In `@pacquet/crates/cli/src/cli_args/setup/tests.rs`:
- Around line 211-212: The warning checks in the setup tests use contains-based
assertions on warnings[0], so add a debug log of the captured warning before
those assertions to make failures easier to diagnose. Update the relevant test
in setup/tests.rs near the warnings[0] checks by printing or dbg-ing warnings[0]
first, then keep the existing contains assertions against GITHUB_ENV and the
github_env path.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 82822651-2728-47e4-99e0-78d23566b0af

📥 Commits

Reviewing files that changed from the base of the PR and between 83ba18e and a906cbf.

📒 Files selected for processing (2)
  • pacquet/crates/cli/src/cli_args/setup.rs
  • pacquet/crates/cli/src/cli_args/setup/tests.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • pacquet/crates/cli/src/cli_args/setup.rs

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Jul 7, 2026
@scarab-systems
scarab-systems force-pushed the fix-pnpm-9191-global-bin-dir branch from 3cdc656 to 3f57e2b Compare July 11, 2026 16:31
@greptile-apps

greptile-apps Bot commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

Safe to merge. The change is additive, well-guarded, and tested end-to-end in both the TypeScript CLI and the Rust port.

Both implementations validate inputs before touching any state, write only after the primary setup operation succeeds, and handle every error path (missing file, non-regular file, symlink, disk errors) by warning rather than crashing. Test coverage is thorough with no obvious gaps.

No files require special attention.

Reviews (8): Last reviewed commit: "refactor(setup): spell the GitHub Action..." | Re-trigger Greptile

@github-actions

github-actions Bot commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/12841
Testbedpacquet
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
milliseconds (ms)
(Result Δ%)
Upper Boundary
milliseconds (ms)
(Limit %)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
🚷 view threshold
2,709.98 ms
(-5.91%)Baseline: 2,880.22 ms
3,456.27 ms
(78.41%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
1,880.47 ms
(-6.02%)Baseline: 2,000.99 ms
2,401.19 ms
(78.31%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
569.38 ms
(-14.15%)Baseline: 663.26 ms
795.91 ms
(71.54%)
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
🚷 view threshold
351.15 ms
(-14.65%)Baseline: 411.43 ms
493.72 ms
(71.12%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
2,347.32 ms
(-3.88%)Baseline: 2,442.09 ms
2,930.51 ms
(80.10%)
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
🚷 view threshold
4,404.13 ms
(-2.48%)Baseline: 4,516.35 ms
5,419.62 ms
(81.26%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
243.68 ms
(-15.38%)Baseline: 287.96 ms
345.56 ms
(70.52%)
🐰 View full continuous benchmarking report in Bencher

@github-actions

github-actions Bot commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/12841
Testbedpnpr

⚠️ WARNING: No Threshold found!

Without a Threshold, no Alerts will ever be generated.

Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the --ci-only-thresholds flag.

Click to view all benchmark results
BenchmarkLatencymilliseconds (ms)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
1,422.78 ms
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
292.08 ms
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
292.15 ms
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
⚠️ NO THRESHOLD
84.82 ms
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
1,483.47 ms
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
⚠️ NO THRESHOLD
3,458.36 ms
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
259.03 ms
🐰 View full continuous benchmarking report in Bencher

Write PNPM_HOME to the GitHub Actions environment file.

Add the setup bin directory to the workflow path file.

Later workflow steps can use global pnpm commands.

Keep TypeScript setup and pacquet setup behavior aligned.

Refs pnpm#9191.
scarab-systems and others added 3 commits July 24, 2026 00:58
Validate the persisted values before any side effect in pacquet, matching
the TypeScript CLI, which already validated ahead of the global install.

Raise the pacquet validation failure as
ERR_PNPM_BAD_GITHUB_ACTIONS_ENVIRONMENT_VALUE with the same message the
TypeScript CLI throws.

Reject symlinked targets on Windows in the TypeScript CLI, and skip
non-regular targets silently in both stacks.

Name the failing target in the write-failure warning on both stacks.

Detect ENOENT with util.types.isNativeError instead of instanceof Error,
which is unreliable across Jest realms.

Add pacquet to the changeset and bump it to minor.
@zkochan
zkochan force-pushed the fix-pnpm-9191-global-bin-dir branch from 2879d84 to 65754c1 Compare July 23, 2026 23:18
@qodo-code-review

qodo-code-review Bot commented Jul 23, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (1) 📜 Skill insights (0)

Context used
✅ Compliance rules (platform): 24 rules

Grey Divider


Remediation recommended

1. Windows symlink TOCTOU 🐞 Bug ⛨ Security
Description
On Windows, append_existing_regular_file() does a path-based symlink_metadata() check and then
re-opens the path without a no-follow equivalent, allowing a swap to a symlink/reparse point between
check and open to redirect the append. This undermines the intended “don’t follow symlinks” safety
property specifically on Windows runners.
Code

pnpm/crates/cli/src/cli_args/setup/github_actions_env.rs[R127-154]

+/// The runner creates both files up front, so anything but an existing
+/// regular file at `path` is not the runner's target: skip it instead of
+/// creating it or following a symlink to it.
+fn append_existing_regular_file(path: &Path, line: &str) -> std::io::Result<()> {
+    match fs::symlink_metadata(path) {
+        Ok(metadata) if metadata.file_type().is_file() => {}
+        Ok(_) => return Ok(()),
+        Err(err) if err.kind() == std::io::ErrorKind::NotFound => return Ok(()),
+        Err(err) => return Err(err),
+    }
+    let mut file = match open_existing_file_for_append(path) {
+        Ok(file) => file,
+        Err(err) if err.kind() == std::io::ErrorKind::NotFound => return Ok(()),
+        Err(err) => return Err(err),
+    };
+    if !file.metadata()?.file_type().is_file() {
+        return Ok(());
+    }
+    write_line(&mut file, line)
+}
+
+fn open_existing_file_for_append(path: &Path) -> std::io::Result<File> {
+    let mut options = OpenOptions::new();
+    options.read(true).append(true);
+    #[cfg(unix)]
+    options.custom_flags(libc::O_NOFOLLOW);
+    options.open(path)
+}
Relevance

⭐⭐⭐ High

Repo frequently accepts symlink/path-hardening fixes; Windows no-follow gap undermines intended
safety property.

PR-#13075
PR-#13170
PR-#13161

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The code performs a separate metadata check and only applies O_NOFOLLOW under cfg(unix), leaving
Windows to do a check-then-open sequence without an equivalent atomic no-follow protection.

pnpm/crates/cli/src/cli_args/setup/github_actions_env.rs[130-154]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
The env-file append logic is protected against symlink-following on Unix via `O_NOFOLLOW`, but on Windows it relies on a non-atomic `symlink_metadata()` check before a pathname-based open. An attacker that can replace the runner-created env file between those operations can redirect the append.

### Issue Context
- The code’s comment explicitly states it should not follow symlinks.
- The current mitigation is Unix-only (`O_NOFOLLOW`).

### Fix Focus Areas
- pnpm/crates/cli/src/cli_args/setup/github_actions_env.rs[130-146]
- pnpm/crates/cli/src/cli_args/setup/github_actions_env.rs[148-154]

### Suggested fix
- Add a Windows-specific file-open strategy that refuses reparse points/symlinks at open time (e.g., `std::os::windows::fs::OpenOptionsExt` with `FILE_FLAG_OPEN_REPARSE_POINT`, then verify the opened handle is not a reparse point before writing).
- Keep the existing `symlink_metadata()` checks as defense-in-depth, but don’t rely on them for Windows correctness.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Helpers declared before first use ✓ Resolved 📘 Rule violation ⚙ Maintainability
Description
In setup.ts, multiple new top-level helper functions are declared before their first call site in
the same file. This violates the required declaration ordering and reduces local readability per the
checklist rule.
Code

pnpm11/engine/pm/commands/src/setup/setup.ts[R143-216]

+function validateGitHubActionsEnvironmentFileValues (pnpmHomeDir: string, binDir: string): void {
+  if (!shouldPersistGitHubActionsEnvironmentFiles()) return
+  validateGitHubActionsEnvironmentFileValue('PNPM_HOME', pnpmHomeDir)
+  validateGitHubActionsEnvironmentFileValue('pnpm setup bin directory', binDir)
+}
+
+/**
+ * `GITHUB_ENV` and `GITHUB_PATH` are line-oriented, so a line break in a
+ * persisted value would append attacker-chosen records to the environment of
+ * every later step in the workflow job.
+ */
+function validateGitHubActionsEnvironmentFileValue (name: string, value: string): void {
+  if (value.includes('\n') || value.includes('\r') || value.includes('\0')) {
+    throw new PnpmError('BAD_GITHUB_ACTIONS_ENVIRONMENT_VALUE', `${name} cannot contain newline or NUL characters`)
+  }
+}
+
+function writeGitHubActionsEnvironmentFiles (pnpmHomeDir: string, binDir: string): void {
+  if (!shouldPersistGitHubActionsEnvironmentFiles()) return
+  const githubEnv = process.env.GITHUB_ENV
+  const githubPath = process.env.GITHUB_PATH
+  if (githubEnv != null) {
+    appendGitHubActionsEnvironmentFile('GITHUB_ENV', githubEnv, `PNPM_HOME=${pnpmHomeDir}`)
+  }
+  if (githubPath != null) {
+    appendGitHubActionsEnvironmentFile('GITHUB_PATH', githubPath, binDir)
+  }
+}
+
+function shouldPersistGitHubActionsEnvironmentFiles (): boolean {
+  return process.env.GITHUB_ACTIONS === 'true' && (process.env.GITHUB_ENV != null || process.env.GITHUB_PATH != null)
+}
+
+/**
+ * The runner creates both files up front, so anything but an existing regular
+ * file at `filePath` is not the runner's target: skip it instead of creating
+ * it or following a symlink to it. A failure on one target must not stop the
+ * other from being written.
+ */
+function appendGitHubActionsEnvironmentFile (targetName: string, filePath: string, line: string): void {
+  try {
+    if (!fs.lstatSync(filePath).isFile()) return
+    appendLineToRegularFile(filePath, line)
+  } catch (err: unknown) {
+    if (util.types.isNativeError(err) && (err as NodeJS.ErrnoException).code === 'ENOENT') return
+    logger.warn({
+      message: `Failed to write GitHub Actions environment file ${targetName} (${filePath}): ${util.types.isNativeError(err) ? err.message : String(err)}`,
+      prefix: process.cwd(),
+    })
+  }
+}
+
+function appendLineToRegularFile (filePath: string, line: string): void {
+  const fd = fs.openSync(
+    filePath,
+    fs.constants.O_RDWR |
+      fs.constants.O_APPEND |
+      (process.platform === 'win32' ? 0 : fs.constants.O_NOFOLLOW)
+  )
+  try {
+    const stats = fs.fstatSync(fd)
+    if (!stats.isFile()) return
+    fs.writeSync(fd, `${missingRecordSeparator(fd, stats.size)}${line}\n`, null, 'utf8')
+  } finally {
+    fs.closeSync(fd)
+  }
+}
+
+function missingRecordSeparator (fd: number, size: number): string {
+  if (size === 0) return ''
+  const lastByte = Buffer.allocUnsafe(1)
+  const bytesRead = fs.readSync(fd, lastByte, 0, 1, size - 1)
+  return bytesRead === 1 && lastByte[0] !== 0x0A ? '\n' : ''
+}
Relevance

⭐⭐⭐ High

Repo often enforces “declare functions after first use” ordering; multiple accepted fixes for this
exact rule.

PR-#12954
PR-#12964
PR-#13133

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713432 requires top-level TypeScript function declarations to appear only after at
least one call site in the same file. In setup.ts, helper functions are declared starting at line
143, but the first usage (e.g., calling validateGitHubActionsEnvironmentFileValues(...) and
writeGitHubActionsEnvironmentFiles(...)) occurs later in handler around lines 242 and 255.

Rule 713432: Declare TypeScript functions only after their first usage
pnpm11/engine/pm/commands/src/setup/setup.ts[143-216]
pnpm11/engine/pm/commands/src/setup/setup.ts[239-256]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
TypeScript top-level helper functions (e.g., `validateGitHubActionsEnvironmentFileValues`, `writeGitHubActionsEnvironmentFiles`) are declared before their first usage in the file, but the rule requires declarations to appear only after the first usage.

## Issue Context
This ordering rule applies to top-level function declarations in `.ts` files when they are used in the same file.

## Fix Focus Areas
- pnpm11/engine/pm/commands/src/setup/setup.ts[143-216]
- pnpm11/engine/pm/commands/src/setup/setup.ts[239-256]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Unsanitized env-file warnings ✓ Resolved 🐞 Bug ⛨ Security
Description
When GitHub Actions env-file writes fail, the warning message interpolates the env-controlled file
path (and the OS error text) without stripping control characters, enabling CI log/terminal
injection (e.g., newlines/escapes in GITHUB_ENV). This regresses the repo’s established pattern of
sanitizing untrusted log content before printing.
Code

pnpm11/engine/pm/commands/src/setup/setup.ts[R182-192]

+function appendGitHubActionsEnvironmentFile (targetName: string, filePath: string, line: string): void {
+  try {
+    if (!fs.lstatSync(filePath).isFile()) return
+    appendLineToRegularFile(filePath, line)
+  } catch (err: unknown) {
+    if (util.types.isNativeError(err) && (err as NodeJS.ErrnoException).code === 'ENOENT') return
+    logger.warn({
+      message: `Failed to write GitHub Actions environment file ${targetName} (${filePath}): ${util.types.isNativeError(err) ? err.message : String(err)}`,
+      prefix: process.cwd(),
+    })
+  }
Relevance

⭐⭐⭐ High

Team recently accepted sanitizing/redacting untrusted GitHub Actions warning content to prevent
log/control-character injection.

PR-#13230

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The warning path comes from environment variables and is interpolated directly into log output; the
repo already ships sanitizers specifically to strip control characters from untrusted output and
uses them for GitHub Actions-related warnings elsewhere.

pnpm11/engine/pm/commands/src/setup/setup.ts[172-206]
pnpm/crates/cli/src/cli_args/setup.rs[154-203]
pnpm11/core/error/src/index.ts[104-123]
pnpm/crates/cli/src/cli_args/sanitize.rs[17-24]
pnpm11/deps/github-actions/src/index.ts[157-163]
PR-#13230

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`pnpm setup` logs warnings that embed `GITHUB_ENV`/`GITHUB_PATH` (environment-controlled) and error strings without sanitization. This allows control characters to reach terminal/CI logs, enabling log injection.

### Issue Context
The repo already has sanitization utilities used for similar scenarios (`redactAndSanitize` in TS, `sanitize_inline` in Rust), and GitHub Actions-related warnings elsewhere already use them.

### Fix Focus Areas
- pnpm11/engine/pm/commands/src/setup/setup.ts[182-192]
- pnpm/crates/cli/src/cli_args/setup.rs[188-202]
- pnpm11/core/error/src/index.ts[104-123]
- pnpm/crates/cli/src/cli_args/sanitize.rs[17-24]

### Suggested change
- **TypeScript**: wrap the composed warning string with `redactAndSanitize(...)` (or at minimum strip control characters from `filePath` and the formatted error string) before passing it to `logger.warn`.
- **Rust**: sanitize `path.display().to_string()` and `err.to_string()` (e.g., `sanitize_inline`) before formatting/emitting the warning.
- Keep the message single-line (strip `\r`/`\n`) to avoid structured log corruption.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View more (1)
4. Spoofable env-file paths ✓ Resolved 🐞 Bug ⛨ Security
Description
The new GitHub Actions persistence writes to paths taken directly from GITHUB_ENV/GITHUB_PATH
when GITHUB_ACTIONS='true' without verifying those paths are runner-managed env files, so a
spoofed environment can make pnpm setup append fixed lines to any existing regular file. This
expands the impact of untrusted environment variables from “log shaping” to a filesystem write
primitive (fixed content, attacker-chosen destination).
Code

pnpm11/engine/pm/commands/src/setup/setup.ts[R160-186]

+function writeGitHubActionsEnvironmentFiles (pnpmHomeDir: string, binDir: string): void {
+  if (!shouldPersistGitHubActionsEnvironmentFiles()) return
+  const githubEnv = process.env.GITHUB_ENV
+  const githubPath = process.env.GITHUB_PATH
+  if (githubEnv != null) {
+    appendGitHubActionsEnvironmentFile('GITHUB_ENV', githubEnv, `PNPM_HOME=${pnpmHomeDir}`)
+  }
+  if (githubPath != null) {
+    appendGitHubActionsEnvironmentFile('GITHUB_PATH', githubPath, binDir)
+  }
+}
+
+function shouldPersistGitHubActionsEnvironmentFiles (): boolean {
+  return process.env.GITHUB_ACTIONS === 'true' && (process.env.GITHUB_ENV != null || process.env.GITHUB_PATH != null)
+}
+
+/**
+ * The runner creates both files up front, so anything but an existing regular
+ * file at `filePath` is not the runner's target: skip it instead of creating
+ * it or following a symlink to it. A failure on one target must not stop the
+ * other from being written.
+ */
+function appendGitHubActionsEnvironmentFile (targetName: string, filePath: string, line: string): void {
+  try {
+    if (!fs.lstatSync(filePath).isFile()) return
+    appendLineToRegularFile(filePath, line)
+  } catch (err: unknown) {
Relevance

⭐⭐ Medium

Security hardening is common, but no close precedent requiring runner-provenance allowlisting for
GITHUB_ENV/PATH destinations.

PR-#12669
PR-#12609
PR-#12777

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Both implementations gate only on GITHUB_ACTIONS + presence of the variables, then use the
variable values as file paths for appending; there is no allowlist/provenance check tying them to
the runner’s env-file directory.

pnpm11/engine/pm/commands/src/setup/setup.ts[160-174]
pnpm11/engine/pm/commands/src/setup/setup.ts[182-206]
pnpm/crates/cli/src/cli_args/setup.rs[117-157]
pnpm/crates/cli/src/cli_args/setup.rs[205-230]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`pnpm setup` treats `GITHUB_ENV`/`GITHUB_PATH` as authoritative file paths as long as `GITHUB_ACTIONS === 'true'` and the vars are present. Because env vars are attacker-controlled by default, this enables appending pnpm-controlled lines to any *existing* regular file chosen via those env vars.

### Issue Context
Current mitigations help (skip missing files, skip non-regular files, `O_NOFOLLOW` on Unix), but they don’t establish that the destination path is *the* GitHub runner env-file.

### Fix Focus Areas
- pnpm11/engine/pm/commands/src/setup/setup.ts[160-174]
- pnpm11/engine/pm/commands/src/setup/setup.ts[182-201]
- pnpm/crates/cli/src/cli_args/setup.rs[117-161]
- pnpm/crates/cli/src/cli_args/setup.rs[205-230]

### Suggested change
Implement an additional provenance check before writing:
- Require `RUNNER_TEMP` (and/or `GITHUB_RUN_ID`) to be set, and require `GITHUB_ENV`/`GITHUB_PATH` to be absolute and under the expected runner directory (commonly `$RUNNER_TEMP/_runner_file_commands/`).
- If the path fails validation, **skip writing** and emit a sanitized warning.
- Apply the same rule in both TS and Rust to keep behavior aligned.

This keeps the feature working in real GitHub Actions while preventing spoofed environments from redirecting writes to arbitrary existing files.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Informational

5. fs.openSync missing trailing comma 📘 Rule violation ⚙ Maintainability ⭐ New
Description
The multi-line fs.openSync( call omits a trailing comma after the last argument, violating the
required trailing-comma style for multi-line TypeScript constructs. This causes inconsistent
formatting and noisier diffs when arguments are edited or reordered.
Code

pnpm11/engine/pm/commands/src/setup/ghActionsEnv.ts[R72-78]

+function appendLineToRegularFile (filePath: string, line: string): void {
+  const fd = fs.openSync(
+    filePath,
+    fs.constants.O_RDWR |
+      fs.constants.O_APPEND |
+      (process.platform === 'win32' ? 0 : fs.constants.O_NOFOLLOW)
+  )
Relevance

⭐ Low

Repo history shows trailing-comma style nits in multiline constructs were explicitly rejected as
low-value formatting churn.

PR-#13064
PR-#13133

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713434 requires trailing commas in multi-line TypeScript constructs. The
fs.openSync( invocation spans multiple lines and the final argument line ends without a comma
before the closing ).

Rule 713434: Require trailing commas in TypeScript collections and multi-line constructs
pnpm11/engine/pm/commands/src/setup/ghActionsEnv.ts[72-78]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
A multi-line argument list in `fs.openSync(...)` is missing a trailing comma after the last argument.

## Issue Context
This repo requires trailing commas in TypeScript multi-line constructs to keep diffs stable and formatting consistent.

## Fix Focus Areas
- pnpm11/engine/pm/commands/src/setup/ghActionsEnv.ts[72-78]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Previous review results

Review updated until commit e97a233

Results up to commit 65754c1 ⚖️ Balanced


🐞 Bugs (1) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)


Remediation recommended
1. Unsanitized env-file warnings 🐞 Bug ⛨ Security
Description
When GitHub Actions env-file writes fail, the warning message interpolates the env-controlled file
path (and the OS error text) without stripping control characters, enabling CI log/terminal
injection (e.g., newlines/escapes in GITHUB_ENV). This regresses the repo’s established pattern of
sanitizing untrusted log content before printing.
Code

pnpm11/engine/pm/commands/src/setup/setup.ts[R182-192]

+function appendGitHubActionsEnvironmentFile (targetName: string, filePath: string, line: string): void {
+  try {
+    if (!fs.lstatSync(filePath).isFile()) return
+    appendLineToRegularFile(filePath, line)
+  } catch (err: unknown) {
+    if (util.types.isNativeError(err) && (err as NodeJS.ErrnoException).code === 'ENOENT') return
+    logger.warn({
+      message: `Failed to write GitHub Actions environment file ${targetName} (${filePath}): ${util.types.isNativeError(err) ? err.message : String(err)}`,
+      prefix: process.cwd(),
+    })
+  }
Relevance

⭐⭐⭐ High

Team recently accepted sanitizing/redacting untrusted GitHub Actions warning content to prevent
log/control-character injection.

PR-#13230

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The warning path comes from environment variables and is interpolated directly into log output; the
repo already ships sanitizers specifically to strip control characters from untrusted output and
uses them for GitHub Actions-related warnings elsewhere.

pnpm11/engine/pm/commands/src/setup/setup.ts[172-206]
pnpm/crates/cli/src/cli_args/setup.rs[154-203]
pnpm11/core/error/src/index.ts[104-123]
pnpm/crates/cli/src/cli_args/sanitize.rs[17-24]
pnpm11/deps/github-actions/src/index.ts[157-163]
PR-#13230

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`pnpm setup` logs warnings that embed `GITHUB_ENV`/`GITHUB_PATH` (environment-controlled) and error strings without sanitization. This allows control characters to reach terminal/CI logs, enabling log injection.

### Issue Context
The repo already has sanitization utilities used for similar scenarios (`redactAndSanitize` in TS, `sanitize_inline` in Rust), and GitHub Actions-related warnings elsewhere already use them.

### Fix Focus Areas
- pnpm11/engine/pm/commands/src/setup/setup.ts[182-192]
- pnpm/crates/cli/src/cli_args/setup.rs[188-202]
- pnpm11/core/error/src/index.ts[104-123]
- pnpm/crates/cli/src/cli_args/sanitize.rs[17-24]

### Suggested change
- **TypeScript**: wrap the composed warning string with `redactAndSanitize(...)` (or at minimum strip control characters from `filePath` and the formatted error string) before passing it to `logger.warn`.
- **Rust**: sanitize `path.display().to_string()` and `err.to_string()` (e.g., `sanitize_inline`) before formatting/emitting the warning.
- Keep the message single-line (strip `\r`/`\n`) to avoid structured log corruption.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Helpers declared before first use ✓ Resolved 📘 Rule violation ⚙ Maintainability
Description
In setup.ts, multiple new top-level helper functions are declared before their first call site in
the same file. This violates the required declaration ordering and reduces local readability per the
checklist rule.
Code

pnpm11/engine/pm/commands/src/setup/setup.ts[R143-216]

+function validateGitHubActionsEnvironmentFileValues (pnpmHomeDir: string, binDir: string): void {
+  if (!shouldPersistGitHubActionsEnvironmentFiles()) return
+  validateGitHubActionsEnvironmentFileValue('PNPM_HOME', pnpmHomeDir)
+  validateGitHubActionsEnvironmentFileValue('pnpm setup bin directory', binDir)
+}
+
+/**
+ * `GITHUB_ENV` and `GITHUB_PATH` are line-oriented, so a line break in a
+ * persisted value would append attacker-chosen records to the environment of
+ * every later step in the workflow job.
+ */
+function validateGitHubActionsEnvironmentFileValue (name: string, value: string): void {
+  if (value.includes('\n') || value.includes('\r') || value.includes('\0')) {
+    throw new PnpmError('BAD_GITHUB_ACTIONS_ENVIRONMENT_VALUE', `${name} cannot contain newline or NUL characters`)
+  }
+}
+
+function writeGitHubActionsEnvironmentFiles (pnpmHomeDir: string, binDir: string): void {
+  if (!shouldPersistGitHubActionsEnvironmentFiles()) return
+  const githubEnv = process.env.GITHUB_ENV
+  const githubPath = process.env.GITHUB_PATH
+  if (githubEnv != null) {
+    appendGitHubActionsEnvironmentFile('GITHUB_ENV', githubEnv, `PNPM_HOME=${pnpmHomeDir}`)
+  }
+  if (githubPath != null) {
+    appendGitHubActionsEnvironmentFile('GITHUB_PATH', githubPath, binDir)
+  }
+}
+
+function shouldPersistGitHubActionsEnvironmentFiles (): boolean {
+  return process.env.GITHUB_ACTIONS === 'true' && (process.env.GITHUB_ENV != null || process.env.GITHUB_PATH != null)
+}
+
+/**
+ * The runner creates both files up front, so anything but an existing regular
+ * file at `filePath` is not the runner's target: skip it instead of creating
+ * it or following a symlink to it. A failure on one target must not stop the
+ * other from being written.
+ */
+function appendGitHubActionsEnvironmentFile (targetName: string, filePath: string, line: string): void {
+  try {
+    if (!fs.lstatSync(filePath).isFile()) return
+    appendLineToRegularFile(filePath, line)
+  } catch (err: unknown) {
+    if (util.types.isNativeError(err) && (err as NodeJS.ErrnoException).code === 'ENOENT') return
+    logger.warn({
+      message: `Failed to write GitHub Actions environment file ${targetName} (${filePath}): ${util.types.isNativeError(err) ? err.message : String(err)}`,
+      prefix: process.cwd(),
+    })
+  }
+}
+
+function appendLineToRegularFile (filePath: string, line: string): void {
+  const fd = fs.openSync(
+    filePath,
+    fs.constants.O_RDWR |
+      fs.constants.O_APPEND |
+      (process.platform === 'win32' ? 0 : fs.constants.O_NOFOLLOW)
+  )
+  try {
+    const stats = fs.fstatSync(fd)
+    if (!stats.isFile()) return
+    fs.writeSync(fd, `${missingRecordSeparator(fd, stats.size)}${line}\n`, null, 'utf8')
+  } finally {
+    fs.closeSync(fd)
+  }
+}
+
+function missingRecordSeparator (fd: number, size: number): string {
+  if (size === 0) return ''
+  const lastByte = Buffer.allocUnsafe(1)
+  const bytesRead = fs.readSync(fd, lastByte, 0, 1, size - 1)
+  return bytesRead === 1 && lastByte[0] !== 0x0A ? '\n' : ''
+}
Relevance

⭐⭐⭐ High

Repo often enforces “declare functions after first use” ordering; multiple accepted fixes for this
exact rule.

PR-#12954
PR-#12964
PR-#13133

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713432 requires top-level TypeScript function declarations to appear only after at
least one call site in the same file. In setup.ts, helper functions are declared starting at line
143, but the first usage (e.g., calling validateGitHubActionsEnvironmentFileValues(...) and
writeGitHubActionsEnvironmentFiles(...)) occurs later in handler around lines 242 and 255.

Rule 713432: Declare TypeScript functions only after their first usage
pnpm11/engine/pm/commands/src/setup/setup.ts[143-216]
pnpm11/engine/pm/commands/src/setup/setup.ts[239-256]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
TypeScript top-level helper functions (e.g., `validateGitHubActionsEnvironmentFileValues`, `writeGitHubActionsEnvironmentFiles`) are declared before their first usage in the file, but the rule requires declarations to appear only after the first usage.

## Issue Context
This ordering rule applies to top-level function declarations in `.ts` files when they are used in the same file.

## Fix Focus Areas
- pnpm11/engine/pm/commands/src/setup/setup.ts[143-216]
- pnpm11/engine/pm/commands/src/setup/setup.ts[239-256]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Spoofable env-file paths ✓ Resolved 🐞 Bug ⛨ Security
Description
The new GitHub Actions persistence writes to paths taken directly from GITHUB_ENV/GITHUB_PATH
when GITHUB_ACTIONS='true' without verifying those paths are runner-managed env files, so a
spoofed environment can make pnpm setup append fixed lines to any existing regular file. This
expands the impact of untrusted environment variables from “log shaping” to a filesystem write
primitive (fixed content, attacker-chosen destination).
Code

pnpm11/engine/pm/commands/src/setup/setup.ts[R160-186]

+function writeGitHubActionsEnvironmentFiles (pnpmHomeDir: string, binDir: string): void {
+  if (!shouldPersistGitHubActionsEnvironmentFiles()) return
+  const githubEnv = process.env.GITHUB_ENV
+  const githubPath = process.env.GITHUB_PATH
+  if (githubEnv != null) {
+    appendGitHubActionsEnvironmentFile('GITHUB_ENV', githubEnv, `PNPM_HOME=${pnpmHomeDir}`)
+  }
+  if (githubPath != null) {
+    appendGitHubActionsEnvironmentFile('GITHUB_PATH', githubPath, binDir)
+  }
+}
+
+function shouldPersistGitHubActionsEnvironmentFiles (): boolean {
+  return process.env.GITHUB_ACTIONS === 'true' && (process.env.GITHUB_ENV != null || process.env.GITHUB_PATH != null)
+}
+
+/**
+ * The runner creates both files up front, so anything but an existing regular
+ * file at `filePath` is not the runner's target: skip it instead of creating
+ * it or following a symlink to it. A failure on one target must not stop the
+ * other from being written.
+ */
+function appendGitHubActionsEnvironmentFile (targetName: string, filePath: string, line: string): void {
+  try {
+    if (!fs.lstatSync(filePath).isFile()) return
+    appendLineToRegularFile(filePath, line)
+  } catch (err: unknown) {
Relevance

⭐⭐ Medium

Security hardening is common, but no close precedent requiring runner-provenance allowlisting for
GITHUB_ENV/PATH destinations.

PR-#12669
PR-#12609
PR-#12777

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Both implementations gate only on GITHUB_ACTIONS + presence of the variables, then use the
variable values as file paths for appending; there is no allowlist/provenance check tying them to
the runner’s env-file directory.

pnpm11/engine/pm/commands/src/setup/setup.ts[160-174]
pnpm11/engine/pm/commands/src/setup/setup.ts[182-206]
pnpm/crates/cli/src/cli_args/setup.rs[117-157]
pnpm/crates/cli/src/cli_args/setup.rs[205-230]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`pnpm setup` treats `GITHUB_ENV`/`GITHUB_PATH` as authoritative file paths as long as `GITHUB_ACTIONS === 'true'` and the vars are present. Because env vars are attacker-controlled by default, this enables appending pnpm-controlled lines to any *existing* regular file chosen via those env vars.

### Issue Context
Current mitigations help (skip missing files, skip non-regular files, `O_NOFOLLOW` on Unix), but they don’t establish that the destination path is *the* GitHub runner env-file.

### Fix Focus Areas
- pnpm11/engine/pm/commands/src/setup/setup.ts[160-174]
- pnpm11/engine/pm/commands/src/setup/setup.ts[182-201]
- pnpm/crates/cli/src/cli_args/setup.rs[117-161]
- pnpm/crates/cli/src/cli_args/setup.rs[205-230]

### Suggested change
Implement an additional provenance check before writing:
- Require `RUNNER_TEMP` (and/or `GITHUB_RUN_ID`) to be set, and require `GITHUB_ENV`/`GITHUB_PATH` to be absolute and under the expected runner directory (commonly `$RUNNER_TEMP/_runner_file_commands/`).
- If the path fails validation, **skip writing** and emit a sanitized warning.
- Apply the same rule in both TS and Rust to keep behavior aligned.

This keeps the feature working in real GitHub Actions while preventing spoofed environments from redirecting writes to arbitrary existing files.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Results up to commit c3433ac ⚖️ Balanced


🐞 Bugs (1) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)


Remediation recommended
1. Windows symlink TOCTOU 🐞 Bug ⛨ Security
Description
On Windows, append_existing_regular_file() does a path-based symlink_metadata() check and then
re-opens the path without a no-follow equivalent, allowing a swap to a symlink/reparse point between
check and open to redirect the append. This undermines the intended “don’t follow symlinks” safety
property specifically on Windows runners.
Code

pnpm/crates/cli/src/cli_args/setup/github_actions_env.rs[R127-154]

+/// The runner creates both files up front, so anything but an existing
+/// regular file at `path` is not the runner's target: skip it instead of
+/// creating it or following a symlink to it.
+fn append_existing_regular_file(path: &Path, line: &str) -> std::io::Result<()> {
+    match fs::symlink_metadata(path) {
+        Ok(metadata) if metadata.file_type().is_file() => {}
+        Ok(_) => return Ok(()),
+        Err(err) if err.kind() == std::io::ErrorKind::NotFound => return Ok(()),
+        Err(err) => return Err(err),
+    }
+    let mut file = match open_existing_file_for_append(path) {
+        Ok(file) => file,
+        Err(err) if err.kind() == std::io::ErrorKind::NotFound => return Ok(()),
+        Err(err) => return Err(err),
+    };
+    if !file.metadata()?.file_type().is_file() {
+        return Ok(());
+    }
+    write_line(&mut file, line)
+}
+
+fn open_existing_file_for_append(path: &Path) -> std::io::Result<File> {
+    let mut options = OpenOptions::new();
+    options.read(true).append(true);
+    #[cfg(unix)]
+    options.custom_flags(libc::O_NOFOLLOW);
+    options.open(path)
+}
Relevance

⭐⭐⭐ High

Repo frequently accepts symlink/path-hardening fixes; Windows no-follow gap undermines intended
safety property.

PR-#13075
PR-#13170
PR-#13161

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The code performs a separate metadata check and only applies O_NOFOLLOW under cfg(unix), leaving
Windows to do a check-then-open sequence without an equivalent atomic no-follow protection.

pnpm/crates/cli/src/cli_args/setup/github_actions_env.rs[130-154]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
The env-file append logic is protected against symlink-following on Unix via `O_NOFOLLOW`, but on Windows it relies on a non-atomic `symlink_metadata()` check before a pathname-based open. An attacker that can replace the runner-created env file between those operations can redirect the append.

### Issue Context
- The code’s comment explicitly states it should not follow symlinks.
- The current mitigation is Unix-only (`O_NOFOLLOW`).

### Fix Focus Areas
- pnpm/crates/cli/src/cli_args/setup/github_actions_env.rs[130-146]
- pnpm/crates/cli/src/cli_args/setup/github_actions_env.rs[148-154]

### Suggested fix
- Add a Windows-specific file-open strategy that refuses reparse points/symlinks at open time (e.g., `std::os::windows::fs::OpenOptionsExt` with `FILE_FLAG_OPEN_REPARSE_POINT`, then verify the opened handle is not a reparse point before writing).
- Keep the existing `symlink_metadata()` checks as defense-in-depth, but don’t rely on them for Windows correctness.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Qodo Logo

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

Route the GITHUB_ACTIONS, GITHUB_ENV, and GITHUB_PATH lookups through the
EnvVarOs capability seam instead of calling std::env::var_os in library
code, per the "Reading process state" section of the pacquet code style
guide. Tests can now drive the inside-a-workflow and outside-a-workflow
branches with a fake provider rather than only the write helpers.

Put the pacquet side in cli_args/setup/github_actions_env.rs with its unit
tests in the external tests submodule, and the TypeScript side in
setup/githubActionsEnv.ts, so setup.rs and setup.ts are back to the
install-and-extend-PATH flow alone.
@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit c3433ac

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

zkochan added 2 commits July 24, 2026 01:37
…mments

Let the module carry the context the names were repeating, so
validateGitHubActionsEnvironmentFileValues becomes validateValues and
writeGitHubActionsEnvironmentFiles becomes persist, matching the pacquet
side. The TypeScript caller imports the module as a namespace, the way
self-updater/index.ts already does, so the call sites still read as
githubActionsEnv.persist.

State the why once in the module doc instead of re-deriving it on each
helper, drop the doc comments that only restated a name or narrated a
scenario a test already asserts, and restructure the prose that leaned on
mid-sentence em dashes.
"unwritable" is not in the repo dictionary, and the phrase reads better
spelled out.
@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 2550571

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

…and Env

Restore self-describing names for every function that touches the workflow
env files, abbreviating GitHubActions to GHActions and Environment to Env so
they stay readable. The TypeScript caller goes back to named imports, since
the names no longer lean on the module prefix for meaning.

Rename the modules to match: gh_actions_env.rs and ghActionsEnv.ts.
@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit e97a233

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ERR_PNPM_NO_GLOBAL_BIN_DIR after corepack enable + pnpm setup on GitHub Actions

3 participants