← Back to issue list

Calling snapcraft clean shouldn't load the project

View original Launchpad issue

Metadata

Project
snapcraft
Number
#2028047
Type
issue
State
open
Author
~gbeuzeboc
Labels
Created
2023-07-18 09:43:41.233395+00:00
Updated
2023-07-18 09:43:41.233395+00:00
Closed

Current evaluation

No evaluation has been recorded for this issue yet.

Issue body

The call to the lifecycle.clean method calls the project_loader.load_config which calls the pluginhandler.load_plugin 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://github.com/ubuntu-robotics/ros-snaps-examples/tree/main/source_pkg_noetic_core20) - 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.

Evaluation history

No evaluation history available.