Skip to content

Commit 68bb93f

Browse files
committed
fix: pip 22 compatibility for base tools and install commands
- Base tools: try pip3 install without --break-system-packages first (pip 22) - fix_pip_pep668: wrap with fallback (pip 23+ flag || plain pip 22) - Fixes pytest not found on Ubuntu 22.04 containers (pip 22.0.2)
1 parent a0c1d6f commit 68bb93f

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

src/executor.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,16 @@ fn filter_install_command(cmd: &str) -> String {
138138
}
139139

140140
fn fix_pip_pep668(cmd: &str) -> String {
141+
// Try --break-system-packages first (pip 23+), fall back to plain pip (pip 22)
141142
if (cmd.contains("pip install") || cmd.contains("pip3 install"))
142143
&& !cmd.contains("--break-system-packages")
143144
&& !cmd.contains("venv")
144145
{
145-
cmd.replace("pip install", "pip install --break-system-packages")
146-
.replace("pip3 install", "pip3 install --break-system-packages")
146+
// Wrap with fallback: try with flag first, if it fails (old pip), retry without
147+
let with_flag = cmd
148+
.replace("pip install", "pip install --break-system-packages")
149+
.replace("pip3 install", "pip3 install --break-system-packages");
150+
format!("({} 2>&1 || {})", with_flag, cmd)
147151
} else {
148152
cmd.to_string()
149153
}
@@ -761,8 +765,8 @@ async fn run_task_on_basilica(
761765
sudo apt-get install -y -qq git curl build-essential python3 python3-pip python3-venv unzip > /dev/null 2>&1 && \
762766
sudo ln -sf /usr/bin/python3 /usr/local/bin/python 2>/dev/null; \
763767
sudo ln -sf /usr/bin/pip3 /usr/local/bin/pip 2>/dev/null; \
764-
sudo python3 -m pip install --break-system-packages pytest > /dev/null 2>&1; \
765-
sudo ln -sf /usr/local/bin/pytest /usr/bin/pytest 2>/dev/null; true"
768+
sudo pip3 install pytest > /dev/null 2>&1 || sudo pip3 install --break-system-packages pytest > /dev/null 2>&1; \
769+
hash -r 2>/dev/null; true"
766770
);
767771
let (_, _, exit) = ssh_exec(host, port, user, &base_tools, timeout, ssh_key).await?;
768772
if exit != 0 {

0 commit comments

Comments
 (0)