Calling snapcraft clean shouldn't load the project
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Snapcraft |
New
|
Undecided
|
Unassigned |
Bug Description
The call to the lifecycle.clean method calls the
project_
This load_plugin method is using sys.path to load plugins. This is using the host sys.path (while cleaning a container/VM used to build the snap).
If the host has a Python module with the same name as the snapcraft plugin, it will try to load the Python module from the host. The module from the host being something completely unrelated to snapcraft plugins, the load crashes.
When calling snapcraft clean, snapcraft shouldn't try to load python module from the host or even parse/load the project.
A simple way to reproduce the error is to:
- Source a ROS Noetic environment (Expanding PYTHONPATH with a ROS dedicated path on the host)
- Call snapcraft --use-lxd to build a ROS 1 Noetic snap (an example can be found here: https:/
- Run snapcraft clean --use-lxd to clean to snap build env
- It will generate the following error:
Loaded local plugin for catkin
Failed to load plugin: unknown plugin: 'catkin'
It happens because it tries to load a local plugin found in the PYTHONPATH. The "local plugin" is simply a Python module from the host that was added to the PYTHONPATH when sourcing our environment.