Fix poetry installation on macOS when Python from Xcode Command Line Tools - #186
Closed
caorantaoyao wants to merge 2 commits into
Closed
Fix poetry installation on macOS when Python from Xcode Command Line Tools#186caorantaoyao wants to merge 2 commits into
caorantaoyao wants to merge 2 commits into
Conversation
|
@caorantaoyao is attempting to deploy a commit to the Poetry Team on Vercel. A member of the Team first needs to authorize it. |
for more information, see https://pre-commit.ci
Author
|
Duplicate of #187. Closing in favor of the updated PR. |
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.
Root cause: On macOS, when Python 3.x is installed by the Xcode Command Line Tools, the base interpreter is a stub (e.g.
/usr/bin/python3->/Library/Developer/CommandLineTools/usr/bin/python3). Creating a virtual environment with the stdlibvenvmodule from this stub produces a venv whosebin/pythoncarries an unresolvable@executable_path/../Python3loader reference. As a result, pip (and therefore the poetry install) fails with a dyld error:Library not loaded: @executable_path/../Python3.Fix: When
sys.platform == "darwin"and the interpreter path points into/Library/Developer/CommandLineTools, force the installer to use the existing virtualenv zipapp bootstrap path (--always-copy), which creates a self-contained virtual environment that is not affected by the broken stdlib venv layout.Behavior: The new branch only triggers on macOS for the Command Line Tools stub interpreter. On all other platforms and Python installations the existing
venvcode path is unchanged.