Errors in relenv script preventing proper installation of modules
Since about 20 June, some tests and installations of Ubuntu machines involving the pip.installed command have been failing. The problem's appearance coincided with the appearance of pip version 24.1, but the affected Ubuntu machines have version 22.0.2. The affected Ubuntu machines are using relenv version 0.16.0, Python 3.10.14 and salt-minion 3006.8.
The error appears in this way:
ID: pip (This part is okay)Function: pip.installed Result: True Comment: All packages were successfully installed Started: 11:48:07.543580 Duration: 9436.212 ms Changes:
---------- pip==24.1: InstalledID: pyinotifyFunction: pip.installed Result: False Comment: Failed to install packages: pyinotify. Error: Looking in indexes: (index removed) Collecting pyinotify Downloading (URL removed) (60 kB) >â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â”â” 61.0/61.0 kB 1.0 MB/s eta 0:00:00 Preparing metadata (setup.py): started Preparing metadata (setup.py): finished with status 'done' Building wheels for collected packages: pyinotify Building wheel for pyinotify (setup.py): started Building wheel for pyinotify (setup.py): finished with status 'done' Created wheel for pyinotify: filename=pyinotify-0.9.6-py3-none-any.whl size=25342 sha256=2ed656274ed34a4ddf69abdcf7d167729fe972c03b6b4d900e5e1bb4fa8394b7 Stored in directory: /root/.cache/pip/wheels/4a/04/c7/8ad5f6b9280b1fe87df10fd6473716f4f1f6a922fbbfb94bc8 Successfully built pyinotify Installing collected packages: pyinotify ERROR: Exception: Traceback (most recent call last): File "/opt/saltstack/salt/extras-3.10/pip/_internal/cli/base_command.py", line 179, in exc_logging_wrapper status = run_func(*args) File "/opt/saltstack/salt/lib/python3.10/site-packages/relenv/runtime.py", line 638, in wrapper return func(self, options, args) File "/opt/saltstack/salt/extras-3.10/pip/_internal/cli/req_command.py", line 67, in wrapper return func(self, options, args) File "/opt/saltstack/salt/extras-3.10/pip/_internal/commands/install.py", line 455, in run installed = install_given_reqs( File "/opt/saltstack/salt/extras-3.10/pip/_internal/req/init.py", line 70, in install_given_reqs requirement.install( File "/opt/saltstack/salt/lib/python3.10/site-packages/relenv/runtime.py", line 761, in wrapper return func( File "/opt/saltstack/salt/extras-3.10/pip/_internal/req/req_install.py", line 817, in install scheme = get_scheme( File "/opt/saltstack/salt/lib/python3.10/site-packages/relenv/runtime.py", line 673, in wrapper scheme.platlib = TARGET.PATH File "
", line 4, in setattr dataclasses.FrozenInstanceError: cannot assign to field 'platlib' Started: 11:48:17.530499 Duration: 2453.652 ms Changes:
As a result, inotify beacons cannot be configured. This apparently affects at least one other module in pip.install commands. So far, this has only been observed in tests simulating the installation (i.e. initial highstate) of Ubuntu machines and in Ubuntu machines installed after 20 June. Machines installed at or before this date seem unaffected, even when they also have relenv version 0.16.0, Python 3.10.14 as well as salt-minion 3006.8. It is known to affect Ubuntu 20.04 and 22.04. Earlier and later versions of Ubuntu were not tested.
Deleting line 673 of /opt/saltstack/salt/lib/python3.10/site-packages/relenv/runtime.py resulted in the dataclasses.FrozenInstanceError appearing for 'purelib' instead (line 674). Deleting this line too moved the dataclasses.FrozenInstanceError to 'data' (line 675). Deleting line 675 and the if statement in line 672 removed the error messages, but this naturally does not install the module.
Consider to keep pip<=24.0 to resolve this issue.
Works for me with pip==23.3.2
You can downgrade with:
/opt/saltstack/salt/bin/python3 -m pip install pip==24.0
Thank you for the advice, sticky-note. I was confused because the answers from the commands 'pip --version' and 'pip list' indicated that the affected machines had pip version 22.0.2 (from python3-pip installed via apt) instead of 24.1.
Altering the pip state to specify a downgraded pip version prevented the problem from appearing in other machines.
In machines that were already affected, the problem was always not so easily fixed by a /opt/saltstack/salt/bin/python3 command. In one case, salt-minion and salt-common was removed and then reinstalled, and this allowed the pip state and inotify beacon to finally work.
I have ubuntu 22.04.5 LTS with salt 3006.9 (Sulfur) and pip 22.0.2 (22.0.2+dfsg-1ubuntu0.4).
The following state resulted in the same error and I was able to silence this error by disabling the upgrade: True property for pip.installed:
system_python_pip_packages:
pip.installed:
- pkgs:
- [...]
#- upgrade: True
I hope the fix of #189 will be available in Ubuntu 24.04 when I upgrade in February 2025.