snapcraft does not properly surface an error message during the pip presence checking on the second and subsequent runs

Bug #1882124 reported by Dmitrii Shcherbakov
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Snapcraft
New
Undecided
Unassigned

Bug Description

I ran into https://bugs.launchpad.net/snapcraft/+bug/1864589

from distutils.util import strtobool
modulenotfounderror: no module named 'distutils.util'

However, while debugging this and retrying I only got this printed in the error message which was confusing because snapcraft expects this to fail:

Failed to run '/root/stage/usr/bin/python3 -m pip': Exited with code 1.

I managed to trace what's going on underneath and it looks like the real exception is not properly displayed but it is about the same issue as in lp: #1864589

A full PDB trace:
https://paste.ubuntu.com/p/ykfm7TgVjm/

The real exception that gets raised:
> /snap/snapcraft/x1/lib/python3.6/site-packages/snapcraft/plugins/_python/_pip.py(231)_is_pip_installed()
-> raise e
(Pdb) output.lower()
'traceback (most recent call last):\n file "/root/stage/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main\n "__main__", mod_spec)\n file "/root/stage
/usr/lib/python3.6/runpy.py", line 85, in _run_code\n exec(code, run_globals)\n file "/root/parts/openstack-projects/install/lib/python3.6/site-packages/pip/__mai
n__.py", line 23, in <module>\n from pip._internal.cli.main import main as _main # isort:skip # noqa\n file "/root/parts/openstack-projects/install/lib/python3.6
/site-packages/pip/_internal/cli/main.py", line 10, in <module>\n from pip._internal.cli.autocompletion import autocomplete\n file "/root/parts/openstack-projects
/install/lib/python3.6/site-packages/pip/_internal/cli/autocompletion.py", line 9, in <module>\n from pip._internal.cli.main_parser import create_main_parser\n fi
le "/root/parts/openstack-projects/install/lib/python3.6/site-packages/pip/_internal/cli/main_parser.py", line 7, in <module>\n from pip._internal.cli import cmdop
tions\n file "/root/parts/openstack-projects/install/lib/python3.6/site-packages/pip/_internal/cli/cmdoptions.py", line 19, in <module>\n from distutils.util impo
rt strtobool\nmodulenotfounderror: no module named \'distutils.util\''

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.