← Back to issue list

The Python plugin can create conflicting interpreters

View original Github issue

Metadata

Project
snapcraft
Number
#6411
Type
issue
State
closed
Author
bepri
Labels
Status: Triaged
Created
Updated
Closed

Current evaluation

Closed as fixed by merged PR #6437 (commit 35853fff8): the Python plugin now rewrites shebangs on core26+ to the absolute /snap/<name>/bin/python3 path, removing PATH-order ambiguity with staged /usr/bin/python3.

Resolution: closed resolved

Reason: Maintainer bepri confirmed in the closing comments that PR #6437 ("fix(python-plugin): use absolute path to python interpreter on core26", merged as commit 35853fff8) hardcodes shebangs to /snap/<name>/bin/python3 so the plugin's venv interpreter is always selected, and noted the fix would ship once #6437 is tagged and released. Tracked internally as SNAPCRAFT-1380.

Evaluated by: mr-cal-bot

No scores available.

Issue body

### Check existing issues - [x] I've verified that this bug isn't described by any existing issues. ### Bug description When building a snap that stages its own Python interpreter with `stage-packages` (most notably, on core26) and uses the Python plugin to build, you can end up with two options for Python interpreters making it into the final artifact. There's the system Python from `stage-packages`, at `/bin/python3`, and then the venv Python from the plugin at `/usr/bin/python3`. The venv Python is typically a symlink to the system Python, but the issue arises with things like `PYTHONPATH`. Since these "appear" as different interpreters, they'll search different things for imports, environments, and things such as `pyvenv.cfg`. Most applications want and expect to be ran with the system Python, but the venv Python appears on the `PATH` first. Some current workarounds are: - Unstage the venv interpreter on the Python plugin part - Use layouts to bind `/usr/bin/python3` to `$SNAP/bin/python3` - Mangle your app's `PATH` to put `/bin` first The fix that the Starcraft team seems to agree on is to patch all shebangs to point to `/bin/python3` instead of `/usr/bin/env python3`, that way this interpreter "selection" is more consistent. Relevant forum post: https://forum.snapcraft.io/t/core26-bundled-python-changes/50178/17 ### Steps to reproduce Build a core26 Python project that stages its own Python interpreter and builds with the Python plugin. ### Environment N/A ### snapcraft.yaml ```yaml N/A ``` ### Log output ```shell N/A ```

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha — closed resolved Closed as fixed by merged PR #6437 (commit 35853fff8): the Python plugin now rewrites shebangs on core26+ to the absolute /snap/<name>/bin/python3 path, removing PATH-order ambiguity with staged /usr/bin/python3.
stealth/space-bunny-alpha — closed resolved Maintainer-filed conflict between staged system Python (/usr/bin/python3) and the plugin's venv interpreter (/bin/python3). Fixed by PR #6437 (commit 35853fff8), which hardcodes shebangs to /snap/<name>/current/bin/python3 on core26+.
stealth/space-bunny-alpha
Impact: 58
Quick Win: 17
Complexity: 55
Confidence: 91
Actionability: 66
keep open Triaged core26 Python plugin bug leaves interpreters in /bin and /usr/bin competing. An existing test exposes missing module visibility; the proposed shebang fix remains under discussion.
qwen/qwen3.6-35b-a3b
Impact: 50
Quick Win: 25
Staleness: 0
Complexity: 50
Confidence: 80
Support Request: 0
keep open Python plugin creates conflicting interpreters on core26 when staging Python via stage-packages; shebangs should point to /bin/python3
qwen/qwen3.6-35b-a3b
Impact: 50
Quick Win: 25
Staleness: 10
Complexity: 50
Confidence: 75
Support Request: 10
keep open Python plugin creates conflicting interpreters on core26 when staging Python via stage-packages; team agreed to patch shebangs to /bin/python3
qwen/qwen3.6-35b-a3b
Impact: 70
Quick Win: 28
Staleness: 5
Complexity: 60
Confidence: 85
Support Request: 10
keep open Python plugin creates conflicting interpreters on core26 when staging Python, causing PATH/PYTHONPATH issues. Triaged and acknowledged by maintainers.
qwen3.6-35b-a3b-mtp-q6
Impact: 75
Quick Win: 34
Staleness: 5
Complexity: 55
Confidence: 85
Support Request: 10
keep open Core26 Python plugin creates conflicting interpreters (/bin/python3 vs /usr/bin/python3) causing import issues; suggests patching shebangs to /bin/python3. Issue is triaged and fresh.

Update history

Date Change
updated
updated
closed
updated
updated
updated
updated
updated
created

Related work

  • Likely Fixed By: canonical/snapcraft#6437 (confidence 97%)

    Merged PR by maintainer bepri referenced directly in the closing comments; hardcodes absolute venv interpreter path in rewritten shebangs for core26.

  • Related To: canonical/lxd (confidence 40%)

    Cited as an example of a bind-file workaround for the same interpreter-selection problem.

Related issues

Issue Project State Summary Similarity
#6437 fix(python-plugin): use absolute path to python interpreter on core26 snapcraft merged Merged PR #6437 (commit 35853fff8) fixes #6411: python-plugin now rewrites shebangs to the absolute /snap/<name>/bin/python3 path on core26 instead of relying on env PATH lookup.
79%
#311 plugins: fix python shebang rockcraft merged Merged PR #311 in commit 08e6a28c, replacing hardcoded plugin Python shebangs with ${PARTS_PYTHON_INTERPRETER} so interpreter overrides are honored.
75%
#1850921 Python plugin: file conflicts when using the plugin with a custom version of Python from another part snapcraft (launchpad) open Python plugin reportedly provisions Python 3.5 before a custom-Python part is staged, causing /usr/bin conflicts; this Snapcraft 2.44 report remains untriaged against the current plugin architecture.
72%
#3451 python v2 plugin: fix multiple python parts with staged python snapcraft merged Merged via commit 932288fed, fixing Python v2 plugin file conflicts and broken symlinks when multiple parts staged Python packages by resolving interpreters before venv creation.
72%