snapcraft clean snapcraft fails as it cannot find python
Metadata
Current evaluation
Fixed by snapcore/snapcraft PR #2171, which corrected Python plugin cleanup so `snapcraft clean snapcraft` no longer fails when python3 is unavailable.
Resolution: closed resolved
Reason: The maintainer identified PR #2171 as the proposed fix, and the issue was subsequently closed after that cleanup change resolved the missing-python3 failure.
Evaluated by: mr-cal-bot
No scores available.
Issue body
Building snapcraft with current master or the latest edge (13881c35fa806ff9fe029205737a49393fd48a38) one cannot clean snapcraft with snapcraft due to python3 missing after init. I suspect this is an ordering issue triggering the failure (as it could have failed before too):
Consider that the project was fully primed, so python3 could have been found at one point.
```
$ snapcraft --debug clean snapcraft
Starting snapcraft 2.42.1+git26.4602d03 from /snap/snapcraft/1674/lib/python3.5/site-packages/snapcraft/cli.
Setting up part 'snapcraft' with plugin 'python' and properties {'stage': [], 'prime': [], 'override-build': 'snapcraftctl build\nTRIPLET_PATH="$SNAPCRAFT_PART_INSTALL/usr/lib/$(gcc -print-multiarch)"\nLIBSODIUM=$(readlink -n $TRIPLET_PATH/libsodium.so.18)\nln -s $LIBSODIUM $TRIPLET_PATH/libsodium.so\npatch -d $SNAPCRAFT_PART_INSTALL/lib/python3.5/site-packages -p1 < /home/sergiusens/source/snapcraft/stage/pyyaml-support-high-codepoints.diff\npatch $SNAPCRAFT_PART_INSTALL/usr/lib/python3.5/ctypes/__init__.py /home/sergiusens/source/snapcraft/stage/ctypes_init.diff\n', 'source': '.', 'build-packages': ['build-essential', 'libapt-pkg-dev', 'libffi-dev', 'libssl-dev', 'libsodium-dev', 'liblzma-dev', 'patch', 'sed'], 'requirements': 'requirements.txt', 'override-prime': "snapcraftctl prime\n# Now that everything is built, let's disable user site-packages\n# as stated in PEP-0370\nsed -i usr/lib/python3.5/site.py -e 's/^ENABLE_USER_SITE = None$/ENABLE_USER_SITE = False/'\n# This is the last step, let's now compile all our pyc files.\n./usr/bin/python3 -m compileall .\n", 'stage-packages': ['apt', 'apt-utils', 'binutils', 'execstack', 'gpgv', 'libffi6', 'libsodium18', 'patchelf', 'squashfs-tools', 'xdelta3'], 'plugin': 'python'}.
Setting up part 'patches' with plugin 'dump' and properties {'prime': ['-*.diff'], 'stage': [], 'source': 'patches', 'plugin': 'dump'}.
Setting up part 'bash-completion' with plugin 'dump' and properties {'prime': [], 'stage': ['snapcraft-completion'], 'source': 'debian', 'plugin': 'dump'}.
Cleaning pull step (and all subsequent steps) for snapcraft
Traceback (most recent call last):
File "/snap/snapcraft/1674/bin/snapcraft", line 11, in <module>
load_entry_point('snapcraft==2.42.1', 'console_scripts', 'snapcraft')()
File "/snap/snapcraft/1674/lib/python3.5/site-packages/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/snap/snapcraft/1674/lib/python3.5/site-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/snap/snapcraft/1674/lib/python3.5/site-packages/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/snap/snapcraft/1674/lib/python3.5/site-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/snap/snapcraft/1674/lib/python3.5/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/snap/snapcraft/1674/lib/python3.5/site-packages/snapcraft/cli/lifecycle.py", line 198, in clean
lifecycle.clean(project, parts, step)
File "/snap/snapcraft/1674/lib/python3.5/site-packages/snapcraft/internal/lifecycle/_clean.py", line 205, in clean
_clean_parts(parts, step, config, staged_state, primed_state)
File "/snap/snapcraft/1674/lib/python3.5/site-packages/snapcraft/internal/lifecycle/_clean.py", line 63, in _clean_parts
part_name, step, config, staged_state, primed_state)
File "/snap/snapcraft/1674/lib/python3.5/site-packages/snapcraft/internal/lifecycle/_clean.py", line 36, in _clean_part
config.parts.clean_part(part_name, staged_state, primed_state, step)
File "/snap/snapcraft/1674/lib/python3.5/site-packages/snapcraft/internal/project_loader/_parts_config.py", line 181, in clean_part
part.clean(staged_state, primed_state, step)
File "/snap/snapcraft/1674/lib/python3.5/site-packages/snapcraft/internal/pluginhandler/__init__.py", line 735, in clean
project_staged_state, project_primed_state, step)
File "/snap/snapcraft/1674/lib/python3.5/site-packages/snapcraft/internal/pluginhandler/__init__.py", line 773, in _clean_steps
self.clean_pull()
File "/snap/snapcraft/1674/lib/python3.5/site-packages/snapcraft/internal/pluginhandler/__init__.py", line 397, in clean_pull
self.plugin.clean_pull()
File "/snap/snapcraft/1674/lib/python3.5/site-packages/snapcraft/plugins/python.py", line 218, in clean_pull
self._pip.clean_packages()
File "/snap/snapcraft/1674/lib/python3.5/site-packages/snapcraft/plugins/python.py", line 187, in _pip
stage_dir=self.project.stage_dir)
File "/snap/snapcraft/1674/lib/python3.5/site-packages/snapcraft/plugins/_python/_pip.py", line 133, in __init__
install_dir=self._install_dir)
File "/snap/snapcraft/1674/lib/python3.5/site-packages/snapcraft/plugins/_python/_python_finder.py", line 51, in get_python_command
python_command_name, [stage_dir, install_dir])
snapcraft.plugins._python.errors.MissingPythonCommandError: Unable to find python3, searched: /home/sergiusens/source/snapcraft/stage:/home/sergiusens/source/snapcraft/parts/snapcraft/install
```
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed resolved | Fixed by snapcore/snapcraft PR #2171, which corrected Python plugin cleanup so `snapcraft clean snapcraft` no longer fails when python3 is unavailable. | |
| stealth/space-bunny-alpha | — | closed resolved | Fixed by merged PR #2171, which added Python and Catkin cleanup support; merged as commit a54a7a4a3. | |
| stealth/space-bunny-alpha | — | closed resolved | The Python 3 discovery failure during `snapcraft clean` was fixed by PR #2171, which added cleaning support for the Python and catkin plugins. | |
| qwen/qwen3.6-35b-a3b | — | — | Closed without comments or explicit resolution, likely abandoned or resolved in a later release. The bug reported a MissingPythonCommandError during snapcraft clean due to python3 path resolution ordering. | |
| qwen/qwen3.6-35b-a3b | — | — | Abandoned. The report detailed snapcraft clean failing with a MissingPythonCommandError during Python plugin cleanup due to an ordering problem. |
Update history
| Date | Change |
|---|---|
| created |
Related work
-
Likely Fixed By:
snapcore/snapcraft#2171
(confidence 95%)
The issue comment directly links PR #2171 as the proposed fix for the Python cleanup failure.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #1602379 'snapcraft' and 'snapcraft-parser' need to use '#!/usr/bin/env python3' in the shebang line | snapcraft (launchpad) | closed | Updated snapcraft and snapcraft-parser to use #!/usr/bin/env python3 via merged PR snapcore/snapcraft#649 (commit c156f111c). | |
| #1606894 Not specifying a source for the python{2,3} plugins gives a confusing error message | snapcraft (launchpad) | closed | Fixed by snapcore/snapcraft#771, correcting source handling for Python parts without an explicitly configured source. | |
| #1586546 snapcraft python2 plugin build fails because of .pth and PYTHONPATH test | snapcraft (launchpad) | closed | Fixed Python plugin setup.py handling in snapcore/snapcraft#718, merged as commit 810136457. | |
| #1862163 snapcraft breaks with python app | snapcraft (launchpad) | closed | Snapcraft wrongly rewrote a non-adapter app command into '/usr/bin/python3 $SNAP/...' which snapd rejected. Fixed by merged PR snapcore/snapcraft#2912, shipped in snapcraft 3.10. | |
| #1621540 do not compile with pip | snapcraft (launchpad) | closed | Fixed in snapcore/snapcraft#779 (commit b9e1aabf6): the Python plugin now skips pip compilation of .pyc files, which were removed later anyway. | |
| #1860884 Python plugin: paths for from the snapcraft snap in sys.path break dependencies | snapcraft (launchpad) | closed | Snapcraft's Python plugin no longer leaks its site-packages into part builds. Fixed by snapcore/snapcraft#2901 (c13c79d76a) and released in Snapcraft 3.10. |