Skip to content

fix(py-shim): canonicalize binary path before locating sibling python#1358

Merged
mergify[bot] merged 1 commit into
mainfrom
devs/sileht/fix-py-shim-symlink-discovery/canonicalize-binary-path-locating-sibling-python--c63c92b1
May 5, 2026
Merged

fix(py-shim): canonicalize binary path before locating sibling python#1358
mergify[bot] merged 1 commit into
mainfrom
devs/sileht/fix-py-shim-symlink-discovery/canonicalize-binary-path-locating-sibling-python--c63c92b1

Conversation

@sileht
Copy link
Copy Markdown
Member

@sileht sileht commented May 5, 2026

env::current_exe() returns the symlink path on macOS (and Windows),
not its canonical target. With pipx, ~/.local/bin/mergify is a
symlink into <venv>/bin/mergify where the interpreter lives —
without canonicalizing, the shim probes for python next to the
user-facing symlink and fails on every invocation with "could not
locate a Python interpreter".

Fixes MRGFY-7173

`env::current_exe()` returns the symlink path on macOS (and Windows),
not its canonical target. With pipx, `~/.local/bin/mergify` is a
symlink into `<venv>/bin/mergify` where the interpreter lives —
without canonicalizing, the shim probes for python next to the
user-facing symlink and fails on every invocation with "could not
locate a Python interpreter".

Fixes MRGFY-7173

Change-Id: Ic63c92b155c24fab31d2c7d241f09a3f1e302674
Copilot AI review requested due to automatic review settings May 5, 2026 11:33
@mergify mergify Bot deployed to Mergify Merge Protections May 5, 2026 11:33 Active
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented May 5, 2026

Merge Protections

Your pull request matches the following merge protections and will not be merged until they are valid.

🟢 🤖 Continuous Integration

Wonderful, this rule succeeded.
  • all of:
    • check-success=ci-gate

🟢 👀 Review Requirements

Wonderful, this rule succeeded.
  • any of:
    • #approved-reviews-by>=2
    • author = dependabot[bot]
    • author = mergify-ci-bot
    • author = renovate[bot]

🟢 Enforce conventional commit

Wonderful, this rule succeeded.

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert|ui)(?:\(.+\))?:

🟢 🔎 Reviews

Wonderful, this rule succeeded.
  • #changes-requested-reviews-by = 0
  • #review-requested = 0
  • #review-threads-unresolved = 0

🟢 📕 PR description

Wonderful, this rule succeeded.
  • body ~= (?ms:.{48,})

Copy link
Copy Markdown

Copilot AI left a comment

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 fixes the Python shim’s interpreter discovery when the mergify binary is invoked via a symlink (notably pipx installs), by canonicalizing the binary path before searching for a sibling python executable.

Changes:

  • Refactors python discovery to a helper that canonicalizes the executable path before probing for a sibling interpreter.
  • Adds a Unix regression test ensuring symlink targets are followed during discovery.
  • Adds tempfile as a dev-dependency to support the new regression test.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.

File Description
crates/mergify-py-shim/src/lib.rs Canonicalizes current_exe path via a new helper and adds a regression test for symlinked invocation.
crates/mergify-py-shim/Cargo.toml Adds tempfile dev-dependency for the new test.
Cargo.lock Updates lockfile to include tempfile for the shim crate’s dev-deps.

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

@sileht sileht marked this pull request as ready for review May 5, 2026 11:35
@mergify mergify Bot requested a review from a team May 5, 2026 11:44
@mergify mergify Bot requested a review from a team May 5, 2026 11:58
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented May 5, 2026

Merge Queue Status

  • Entered queue2026-05-05 12:13 UTC · Rule: default
  • Checks skipped · PR is already up-to-date
  • Merged2026-05-05 12:13 UTC · at 44cf9d4cad884eff065a15d49728f3c6e9af0720 · squash

This pull request spent 10 seconds in the queue, including 1 second running CI.

Required conditions to merge

@mergify mergify Bot added the queued label May 5, 2026
@mergify mergify Bot merged commit d31d0b7 into main May 5, 2026
22 checks passed
@mergify mergify Bot deleted the devs/sileht/fix-py-shim-symlink-discovery/canonicalize-binary-path-locating-sibling-python--c63c92b1 branch May 5, 2026 12:14
@mergify mergify Bot removed the queued label May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants