pip_user_install: add --break-system-packages on Ubuntu 24.04+

pip3 install --user alone does not reliably bypass PEP 668 in all 24.04
environments. --break-system-packages (pip 22.3+) is the correct override.
Flag is only added when ubuntu_version_ge "24.04" so it does not run on
Ubuntu 22.04 where pip 22.0 ships and the flag is not yet supported.

https://claude.ai/code/session_01Y4dMKtkqkpvmgDKoRdzhTG
This commit is contained in:
Claude
2026-06-04 00:01:57 +00:00
parent ef08fef540
commit e8667f02cf
+5 -2
View File
@@ -124,9 +124,12 @@ ubuntu_version_ge() {
}
# pip install --user as actual user.
# Centralised so any future version-specific pip flags land in one place.
# --break-system-packages (pip 22.3+) is required on Ubuntu 24.04+ where PEP 668
# marks the system Python as externally managed; --user alone is not always enough.
pip_user_install() {
sudo -u "$ACTUAL_USER" pip3 install --user --quiet "$@"
local flags="--user --quiet"
ubuntu_version_ge "24.04" && flags="$flags --break-system-packages"
sudo -u "$ACTUAL_USER" pip3 install $flags "$@"
}
detect_os