fix(py-shim): canonicalize binary path before locating sibling python#1358
Merged
Conversation
`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
Contributor
Merge ProtectionsYour pull request matches the following merge protections and will not be merged until they are valid. 🟢 🤖 Continuous IntegrationWonderful, this rule succeeded.
🟢 👀 Review RequirementsWonderful, this rule succeeded.
🟢 Enforce conventional commitWonderful, this rule succeeded.Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
🟢 🔎 ReviewsWonderful, this rule succeeded.
🟢 📕 PR descriptionWonderful, this rule succeeded.
|
There was a problem hiding this comment.
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
tempfileas 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.
kozlek
approved these changes
May 5, 2026
jd
approved these changes
May 5, 2026
Contributor
Merge Queue Status
This pull request spent 10 seconds in the queue, including 1 second running CI. Required conditions to merge
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
env::current_exe()returns the symlink path on macOS (and Windows),not its canonical target. With pipx,
~/.local/bin/mergifyis asymlink into
<venv>/bin/mergifywhere 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