Skip to content

fix(uninstall): use --format=freeze (pip 23.0 removed --format=legacy)#1349

Closed
fanxing11 wants to merge 1 commit into
ActivityWatch:masterfrom
fanxing11:fix/uninstall-pip-format
Closed

fix(uninstall): use --format=freeze (pip 23.0 removed --format=legacy)#1349
fanxing11 wants to merge 1 commit into
ActivityWatch:masterfrom
fanxing11:fix/uninstall-pip-format

Conversation

@fanxing11

Copy link
Copy Markdown

Fixes #1343.

pip 23.0 (2023-01-30) removed the deprecated --format=legacy, so on any modern pip scripts/uninstall.sh bails out with:

option --format: invalid choice: 'legacy' (choose from 'columns', 'freeze', 'json')

The outer grep 'aw-' then reads empty stdin, $modules is empty, the loop is a no-op — and the user thinks uninstall worked.

Switched to --format=freeze (output shape aw-core==0.5.x), which is stable across all supported pip versions. Also tweaked the second grep -o to strip on = instead of space so it still picks up just the package name.

Quick check:

$ echo -e 'aw-core==0.5.16\naw-client==0.5.13\nfoo==1.0' | grep '^aw-' | grep -o '^aw-[^=]*'
aw-core
aw-client

bash -n scripts/uninstall.sh passes.

pip 23.0 (2023-01-30) removed the deprecated `--format=legacy` option.
On pip >= 23.0 `scripts/uninstall.sh` fails with:

    option --format: invalid choice: 'legacy' (choose from 'columns', 'freeze', 'json')

The outer `grep 'aw-'` then receives empty stdin, `$modules` stays empty,
the for loop is a no-op and users think uninstall succeeded.

Switch to `--format=freeze` (output shape `aw-core==0.5.x`) and update the
grep to strip on `=` instead of space so package names are extracted
correctly with the new format.

Fixes ActivityWatch#1343
@greptile-apps

greptile-apps Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes scripts/uninstall.sh to work with pip 23.0+, which dropped the deprecated --format=legacy option from pip list. Without the fix, the command errors out silently, leaving $modules empty and skipping all uninstalls.

  • Format flag: --format=legacy--format=freeze, whose package==version output is stable across all supported pip versions.
  • grep anchoring: grep 'aw-' tightened to grep '^aw-' (prevents false matches on packages that merely contain "aw-" mid-name), and the second grep -o updated to strip on = instead of space to match the ==version suffix in freeze output.

Confidence Score: 5/5

Safe to merge — the change is a targeted one-line fix with an explanatory comment and no side effects.

The only change is swapping a pip flag that was removed upstream and adjusting the two downstream grep patterns accordingly. The freeze format is well-established, the grep anchoring is strictly more correct than before, and the PR author verified the pipeline manually. No logic paths were altered beyond this direct fix.

No files require special attention.

Important Files Changed

Filename Overview
scripts/uninstall.sh Replaces removed --format=legacy with --format=freeze and tightens grep patterns to match the new output shape; logic is correct and the fix is well-explained in the comment.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[pip3 list --format=freeze] -->|"aw-core==0.5.16\naw-client==0.5.13\nfoo==1.0\n..."| B["grep '^aw-'"]
    B -->|"aw-core==0.5.16\naw-client==0.5.13"| C["grep -o '^aw-[^=]*'"]
    C -->|"aw-core\naw-client"| D{modules list empty?}
    D -- Yes --> E[No-op, exit]
    D -- No --> F["for module in modules"]
    F --> G["pip3 uninstall -y module"]
    G --> F
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[pip3 list --format=freeze] -->|"aw-core==0.5.16\naw-client==0.5.13\nfoo==1.0\n..."| B["grep '^aw-'"]
    B -->|"aw-core==0.5.16\naw-client==0.5.13"| C["grep -o '^aw-[^=]*'"]
    C -->|"aw-core\naw-client"| D{modules list empty?}
    D -- Yes --> E[No-op, exit]
    D -- No --> F["for module in modules"]
    F --> G["pip3 uninstall -y module"]
    G --> F
Loading

Reviews (1): Last reviewed commit: "fix(uninstall): use --format=freeze (pip..." | Re-trigger Greptile

@TimeToBuildBob

Copy link
Copy Markdown
Contributor

Thanks for the contribution @fanxing11! This is actually a duplicate of #1344 which was already submitted, has full CI green (12/12 checks), and uses a slightly cleaner approach with cut -d'=' -f1 instead of the nested grep -o regex.

Both fixes are correct — the maintainer will pick one to merge. Appreciate you taking the time to submit a fix! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

scripts/uninstall.sh: pip list --format=legacy removed in pip 23.0, script now errors out

3 participants