Skip to content

Instantly share code, notes, and snippets.

@HGStyle
Created April 13, 2025 13:03
Show Gist options
  • Save HGStyle/5de4ce765b9a81fd3f2ea2d6d9947588 to your computer and use it in GitHub Desktop.
Save HGStyle/5de4ce765b9a81fd3f2ea2d6d9947588 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Define the pip config directory and file
PIP_CONFIG_DIR="$HOME/.config/pip"
PIP_CONFIG_FILE="$PIP_CONFIG_DIR/pip.conf"
# Create the config directory if it doesn't exist
mkdir -p "$PIP_CONFIG_DIR"
# Add or update the break-system-packages option
if grep -q "^\[install\]" "$PIP_CONFIG_FILE" 2>/dev/null; then
# [install] section exists; update or append the option
if grep -q "^break-system-packages" "$PIP_CONFIG_FILE"; then
sed -i 's/^break-system-packages.*/break-system-packages = true/' "$PIP_CONFIG_FILE"
else
sed -i '/^\[install\]/a break-system-packages = true' "$PIP_CONFIG_FILE"
fi
else
# Add the [install] section and the option
{
echo "[install]"
echo "break-system-packages = true"
} >> "$PIP_CONFIG_FILE"
fi
echo "✅ pip is now configured to use --break-system-packages by default."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment