Skip to content

Fix Corepack with usr-bin-first shell paths - #11

Merged
brettheap merged 3 commits into
mainfrom
fix/corepack-path-precedence
Jul 25, 2026
Merged

Fix Corepack with usr-bin-first shell paths#11
brettheap merged 3 commits into
mainfrom
fix/corepack-path-precedence

Conversation

@brettheap

@brettheap brettheap commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • preserve Corepack original entry points before installing the runtime cache wrapper
  • intercept both /usr/bin and /usr/local/bin package-manager shims
  • cover mounted shell configurations that put /usr/bin first
  • bump Layer 3 to 1.2.2 and add regression coverage

Validation

  • reproduced the failure under interactive zsh with /usr/bin/pnpm
  • pnpm install passes in /workspace/projects/profile-switcher after the fix
  • pnpm tauri --version reports 2.11.4
  • disposable image tests pass as the runtime user, root, and with explicit COREPACK_HOME
  • shell syntax and git diff --check pass

Summary by Sourcery

Update the user layer Corepack wrapper to handle /usr/bin-first PATH configurations and ensure package manager shims route through a writable per-user cache.

New Features:

  • Add interception of both /usr/bin and /usr/local/bin Corepack and package manager shims via a runtime wrapper.

Bug Fixes:

  • Fix Corepack and pnpm invocation when shells place /usr/bin ahead of /usr/local/bin in PATH.

Enhancements:

  • Preserve original Corepack entry points in a dedicated directory for reliable wrapper chaining.

Build:

  • Bump Layer 3 user-layer Docker image version label from 1.2.1 to 1.2.2.

Documentation:

  • Document that the Layer 3 user image now supports environments where /usr/bin precedes /usr/local/bin in PATH.

Tests:

  • Add a regression test to verify pnpm wrapper behavior with /usr/bin-first PATH ordering.

Copilot AI review requested due to automatic review settings July 25, 2026 19:43
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@brettheap

Copy link
Copy Markdown
Contributor Author

@codex review

@sourcery-ai

sourcery-ai Bot commented Jul 25, 2026

Copy link
Copy Markdown

🧙 Sourcery has finished reviewing your pull request!


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • The Dockerfile loop that snapshots original Corepack binaries assumes each command exists in /usr/bin and is executable; consider making this more defensive (e.g., skipping missing commands or falling back to /usr/local/bin) to avoid build failures on images with different layouts.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The Dockerfile loop that snapshots original Corepack binaries assumes each command exists in `/usr/bin` and is executable; consider making this more defensive (e.g., skipping missing commands or falling back to `/usr/local/bin`) to avoid build failures on images with different layouts.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@brettheap

Copy link
Copy Markdown
Contributor Author

@codex review

@brettheap

Copy link
Copy Markdown
Contributor Author

@sourcery-ai review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the Layer 3 user image Corepack wrapper so that Corepack and its package-manager shims (pnpm/yarn) continue to work when shell PATH ordering prefers /usr/bin over /usr/local/bin, while ensuring Corepack uses a per-user writable cache.

Changes:

  • Preserve original Corepack/package-manager entry points and add wrapper interception for both /usr/bin and /usr/local/bin.
  • Update the wrapper to execute preserved originals instead of calling back into /usr/bin/$command.
  • Add a regression test for /usr/bin-first PATH behavior and bump Layer 3 version to 1.2.2.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
user-layer/Dockerfile Adds preservation of “original” commands and symlinks wrappers into both /usr/bin and /usr/local/bin; bumps layer version.
user-layer/corepack-user-cache Changes wrapper exec target to preserved originals under /usr/local/libexec/workbenches-corepack-original.
devBenches/devcontainer.test/test.sh Adds a regression check for pnpm resolution with /usr/bin-first PATH.
devBenches/devcontainer.test/README.md Documents the new PATH-ordering compatibility for the Layer 3 Corepack cache behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread user-layer/Dockerfile
Comment on lines +39 to 48
RUN set -eux && \
chmod 0755 /usr/local/libexec/workbenches-corepack-user-cache && \
mkdir -p /usr/local/libexec/workbenches-corepack-original && \
for command in corepack pnpm pnpx yarn yarnpkg; do \
original_command="$(readlink -f "/usr/bin/$command")"; \
test -x "$original_command"; \
ln -sfn "$original_command" "/usr/local/libexec/workbenches-corepack-original/$command"; \
ln -sfn /usr/local/libexec/workbenches-corepack-user-cache "/usr/local/bin/$command"; \
ln -sfn /usr/local/libexec/workbenches-corepack-user-cache "/usr/bin/$command"; \
done

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in bfe1372: each original entry point is now renamed in place before either PATH location is rewired. This preserves relative symlinks and regular binaries without recursion. The rebuilt Rust Layer 3 image passes both the real Corepack test and a disposable regular-file preservation test.

Copilot AI review requested due to automatic review settings July 25, 2026 19:46
@brettheap

Copy link
Copy Markdown
Contributor Author

@codex review

@brettheap

Copy link
Copy Markdown
Contributor Author

@sourcery-ai review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

user-layer/Dockerfile:54

  • The “preserve original Corepack entry points” logic currently records originals as symlinks to paths under /usr/bin or /usr/local/bin, but then immediately replaces those same paths with the wrapper. If the original is a regular file (common for /usr/bin/corepack) or if later shims resolve to a command already wrapped earlier in the loop, the preserved symlink will end up pointing back to the wrapper and can recurse.

A safer approach is to snapshot the original executables before any rewiring (e.g., copy them into /usr/local/libexec/workbenches-corepack-original/) and only then replace /usr/bin/* and /usr/local/bin/* with the wrapper.

RUN set -eux && \
    chmod 0755 /usr/local/libexec/workbenches-corepack-user-cache && \
    mkdir -p /usr/local/libexec/workbenches-corepack-original && \
    for command in corepack pnpm pnpx yarn yarnpkg; do \
        if [ -e "/usr/bin/$command" ] || [ -L "/usr/bin/$command" ]; then \
            original_command="/usr/bin/$command"; \
        elif [ -e "/usr/local/bin/$command" ] || [ -L "/usr/local/bin/$command" ]; then \
            original_command="/usr/local/bin/$command"; \
        else \
            echo "Required Corepack command is unavailable: $command" >&2; \
            exit 1; \
        fi; \
        preserved_command="${original_command}.workbenches-original"; \
        mv "$original_command" "$preserved_command"; \
        test -x "$preserved_command"; \
        ln -sfn "$preserved_command" "/usr/local/libexec/workbenches-corepack-original/$command"; \

Copilot AI review requested due to automatic review settings July 25, 2026 19:49
@brettheap
brettheap merged commit d47c353 into main Jul 25, 2026
5 checks passed
@brettheap
brettheap deleted the fix/corepack-path-precedence branch July 25, 2026 19:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants