PIO remote fails on new install (Ubuntu 24.04) due to missing CFFI dependency within penv #5050
Description
Configuration
Operating system: Ubuntu 24.04.1 LTS
PlatformIO Version (platformio --version
): 6.1.16
Description of problem
I performed an install of PIO onto a fresh Ubuntu 24.04 image using the current get_platformio.py script (https://raw.githubusercontent.com/platformio/platformio-core-installer/master/get-platformio.py). The install completes without error, however attempting to run pio remote agent start
produces the following error:
ModuleNotFoundError: Traceback (most recent call last):
File "/home/xxxx/.platformio/penv/lib/python3.12/site-packages/platformio/__main__.py", line 103, in main
cli() # pylint: disable=no-value-for-parameter
^^^^^
File "/home/xxxx/.platformio/penv/lib/python3.12/site-packages/click/core.py", line 1157, in __call__
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/xxxx/.platformio/penv/lib/python3.12/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "/home/xxxx/.platformio/penv/lib/python3.12/site-packages/platformio/cli.py", line 85, in invoke
return super().invoke(ctx)
^^^^^^^^^^^^^^^^^^^
File "/home/xxxx/.platformio/penv/lib/python3.12/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/xxxx/.platformio/penv/lib/python3.12/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/xxxx/.platformio/penv/lib/python3.12/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/xxxx/.platformio/penv/lib/python3.12/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/xxxx/.platformio/penv/lib/python3.12/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/xxxx/.platformio/penv/lib/python3.12/site-packages/platformio/remote/cli.py", line 68, in remote_agent_start
from platformio.remote.client.agent_service import RemoteAgentService
File "/home/xxxx/.platformio/penv/lib/python3.12/site-packages/platformio/remote/client/agent_service.py", line 27, in <module>
from platformio.remote.client.base import RemoteClientBase
File "/home/xxxx/.platformio/penv/lib/python3.12/site-packages/platformio/remote/client/base.py", line 30, in <module>
from platformio.remote.factory.ssl import SSLContextFactory
File "/home/xxxx/.platformio/penv/lib/python3.12/site-packages/platformio/remote/factory/ssl.py", line 16, in <module>
from OpenSSL import SSL # pylint: disable=import-error
^^^^^^^^^^^^^^^^^^^^^^^
File "/home/xxxx/.platformio/packages/contrib-pioremote/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import SSL, crypto
File "/home/xxxx/.platformio/packages/contrib-pioremote/OpenSSL/SSL.py", line 11, in <module>
from OpenSSL._util import (
File "/home/xxxx/.platformio/packages/contrib-pioremote/OpenSSL/_util.py", line 6, in <module>
from cryptography.hazmat.bindings.openssl.binding import Binding
File "/home/xxxx/.platformio/packages/contrib-pioremote/cryptography/hazmat/bindings/openssl/binding.py", line 15, in <module>
from cryptography.exceptions import InternalError
File "/home/xxxx/.platformio/packages/contrib-pioremote/cryptography/exceptions.py", line 9, in <module>
from cryptography.hazmat.bindings._rust import exceptions as rust_exceptions
ModuleNotFoundError: No module named '_cffi_backend'
Having the system package python3-cffi
installed does not resolve this as pio is looking for the library within its penv.
I had this issue immediately after updating from a working 22.04 Ubuntu system, but then reproduced it on an 'out of the box' Ubuntu 24.04.1 image also.
Resolution
Simply adding the cffi package into the platformio penv fixes this issue:
source ~/.platformio/penv/bin/activate
pip install cffi
deactivate
I'm not sure if this is as simple as just adding the cffi package to the python dependencies in the install script or not, but it seems to be a reproducible issue with current Ubuntu LTS.