Hello. I am upgrading a core20 snap to core24, and python3.8 to 3.12.
I’ve changed the snapcraft.yaml syntax to the newer versions and updated the list of packages to stage, and now we build perfectly well, and run on the machine it was built on, but don’t run when moving the snap to another (earlier) ubuntu machine. This makes me think that the packages are not getting staged/linked/patched properly, along with the snapcraft linter saying that libpython3.12.so.1.0
is unused.
The error I get when running on another machine is Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
, which seems to usually be a PYTHONPATH
/PYTHONHOME
issue, but that doesn’t quite make sense here. Looking at the variables the error spits out, on a working (older) version, when running /snap/certbot/current/bin/python3
, sys.prefix
is /snap/certbot/current
, but on the updated version it’s now /usr
; same with exec_prefix
. And sys.path
is similarly pointing to the /usr/lib
pythons instead of inside the snap as well. So maybe this is a problem with patching/rpath somehow? I have added build-attributes: enable-patchelf
to the snapcraft.yaml
, but did the actual patching get changed instead of just defaulting to no patching? Anything else I’m missing here? I’ve scoured the documentation but have run out of things to try.
All changes can be seen in this PR: Update python version in snaps by ohemorange · Pull Request #9956 · certbot/certbot · GitHub
(This was originally posted as an update to this post from 2020, but since I can’t update the title, I’ve created a new topic.) u p.s. I have read the post on updates to classic confinement but I don’t see anything there about what that means I would need to change in practice to get it working again.
Edit: further investigation indicates that something is wrong with /snap/certbot/current/pyvenv.cfg
.
Contents on a working build:
home = /root/parts/certbot/install/bin
include-system-site-packages = false
version = 3.8.10
Contents on the broken build:
home = /root/parts/certbot/install/usr/bin
include-system-site-packages = false
version = 3.12.3
executable = /root/parts/certbot/install/usr/bin/python3.12
command = /root/parts/certbot/install/bin/python3 -m venv --upgrade /root/parts/certbot/install
And then the working build has the following python path variables:
>>> sys._base_executable
'/snap/certbot/x1/bin/python3'
>>> sys.base_prefix
'/snap/certbot/x1/bin/../usr'
>>> sys.base_exec_prefix
'/snap/certbot/x1/bin/../usr'
>>> sys.executable
'/snap/certbot/x1/bin/python3'
>>> sys.prefix
'/snap/certbot/x1'
>>> sys.exec_prefix
'/snap/certbot/x1'
>>> sys.path
['', '/snap/certbot/x1/usr/lib/python38.zip', '/snap/certbot/x1/usr/lib/python3.8', '/snap/certbot/x1/usr/lib/python3.8/lib-dynload', '/snap/certbot/x1/lib/python3.8/site-packages']
and the broken build has instead:
Python path configuration:
PYTHONHOME = (not set)
PYTHONPATH = (not set)
program name = 'python3'
isolated = 0
environment = 1
user site = 1
safe_path = 0
import site = 1
is in build tree = 0
stdlib dir = '/usr/lib/python3.12'
sys._base_executable = '/snap/certbot/x2/usr/bin/python3.12'
sys.base_prefix = '/usr'
sys.base_exec_prefix = '/usr'
sys.platlibdir = 'lib'
sys.executable = '/snap/certbot/x2/bin/python3'
sys.prefix = '/usr'
sys.exec_prefix = '/usr'
sys.path = [
'/usr/lib/python312.zip',
'/usr/lib/python3.12',
'/usr/lib/python3.12/lib-dynload',
]
Now, I can probably just go ahead and manually set PYTHONHOME
and PYTHONPATH
, but that seems unlikely to be addressing the root cause of these issues, which I would rather do.