Open silverdrake11 opened 1 month ago
Thanks for the report.
Yes, this is an unfortunate side effect of the way the charm
plugin works, as it uses PYTHONPATH
to simulate being in the virtual environment. It also has the effect of allowing the import of system Python libraries.
Unfortunately we can't change this, but the next minor release of Charmcraft will include different plugins that use a dispatch file that activates the virtual environment correctly. It still uses PYTHONPATH
, but only for adding charmlibs and the charm itself.
Bug Description
When running subprocesses within the charm code, the Juju Python virtual environment
/var/lib/juju/agents/unit-landscape-server-0/charm/venv/
is included in the system’s PYTHONPATH. This causes conflicts, as we need to use the system Python and its dependencies, not those from the Juju environment.For example this bug https://bugs.launchpad.net/landscape-charm/+bug/2076926, installing a later version of the pydantic package via apt doesn't do anything because the version from the Juju charm virtual environment takes precedence. A similar issue occurred with the distutils package, where the system version was overshadowed.
To Reproduce
We used this workaround to make sure the system Python paths are used by removing Juju's virtual environment from PYTHONPATH before invoking subprocesses:
Environment
22.04 juju --version 3.5.3-genericlinux-amd64
charmcraft.yaml
Relevant log output