Calling snapcraft clean shouldn't load the project

Bug #2028047 reported by Guillaume Beuzeboc
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Snapcraft
New
Undecided
Unassigned

Bug Description

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.

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.