Skip to content

fix(scripts): replace deprecated pip --format=legacy in uninstall.sh#1344

Merged
ErikBjare merged 1 commit into
ActivityWatch:masterfrom
TimeToBuildBob:fix/uninstall-pip-legacy-format
Jul 5, 2026
Merged

fix(scripts): replace deprecated pip --format=legacy in uninstall.sh#1344
ErikBjare merged 1 commit into
ActivityWatch:masterfrom
TimeToBuildBob:fix/uninstall-pip-legacy-format

Conversation

@TimeToBuildBob

Copy link
Copy Markdown
Contributor

Problem

scripts/uninstall.sh uses pip3 list --format=legacy, but the legacy format was removed in pip 23.0 (released 2023-01-30). Running the script errors out with:

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

As a result, $modules is always empty and nothing gets uninstalled.

Fixes #1343.

Fix

Switch to --format=freeze (outputs package==version per line, available since pip's earliest versions) and use cut -d'=' -f1 to extract just the package name.

Before:

modules=$(pip3 list --format=legacy | grep 'aw-' | grep -o '^aw-[^ ]*')

After:

modules=$(pip3 list --format=freeze | grep '^aw-' | cut -d'=' -f1)

Testing

Verified locally with pip 23.x — pip3 list --format=freeze | grep '^aw-' | cut -d'=' -f1 produces correct package names without version suffixes.

…ninstall.sh

pip 23.0 (2023-01-30) removed the 'legacy' format. Switch to --format=freeze
(package==version per line) and use cut -d'=' -f1 to extract just the package
name. Fixes ActivityWatch#1343.
@greptile-apps

greptile-apps Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a broken pip3 list --format=legacy call in scripts/uninstall.sh that has errored out since pip 23.0 removed the legacy format, causing the module list to always be empty and nothing to be uninstalled.

  • Switches to --format=freeze (outputs package==version per line) and uses cut -d'=' -f1 to strip the version suffix, which correctly extracts the package name from the ==-delimited format.
  • Tightens the grep pattern from grep 'aw-' (substring match anywhere) to grep '^aw-' (anchored to line start), which is a minor correctness improvement that avoids false matches on packages whose description or path contains aw-.

Confidence Score: 5/5

Safe to merge — the one-line change restores correct behavior for pip 23+ with no regressions on older pip versions.

The change is minimal and targeted: it swaps a format flag that pip removed in 2023 for the standard freeze format and updates the downstream text parsing accordingly. Both the format output and cut -d'=' -f1 behavior are well-defined, so the new pipeline reliably extracts bare package names. The added ^ anchor on the grep is a small correctness improvement. No logic is altered elsewhere in the script.

No files require special attention.

Important Files Changed

Filename Overview
scripts/uninstall.sh Replaces removed --format=legacy pip flag with --format=freeze and updates the name-extraction pipeline accordingly; the fix is correct and also tightens the grep anchor.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[pip3 list --format=freeze] --> B["Output: package==version per line\ne.g. aw-core==0.5.8\naw-watcher-afk==0.10.1\nnumpy==1.24.0"]
    B --> C["grep '^aw-'\nKeep only lines starting with 'aw-'"]
    C --> D["cut -d'=' -f1\nExtract package name before first '='"]
    D --> E["modules = 'aw-core aw-watcher-afk ...'"]
    E --> F{for each module}
    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] --> B["Output: package==version per line\ne.g. aw-core==0.5.8\naw-watcher-afk==0.10.1\nnumpy==1.24.0"]
    B --> C["grep '^aw-'\nKeep only lines starting with 'aw-'"]
    C --> D["cut -d'=' -f1\nExtract package name before first '='"]
    D --> E["modules = 'aw-core aw-watcher-afk ...'"]
    E --> F{for each module}
    F --> G["pip3 uninstall -y module"]
    G --> F
Loading

Reviews (1): Last reviewed commit: "fix(scripts): replace deprecated pip --f..." | Re-trigger Greptile

@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

Ready for Merge ✅

  • ✅ CI: All checks green (CodeQL, Release build matrix, Greptile review)
  • ✅ Greptile: 5/5 confidence ("safe to merge")
  • ✅ Mergeable, no conflicts

This is a 2-line fix for the deprecated pip3 list --format=legacy (removed in pip 23.0) that caused uninstall.sh to silently uninstall nothing. Switching to --format=freeze | cut -d'=' -f1 is the correct replacement. Ready for a maintainer to squash-merge.

@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

Noting that @fanxing11 submitted a duplicate fix on #1349. Both are correct approaches, but this one is simpler (cut over nested grep -o), was first, and has full CI green (12/12).

Ready for maintainer review + merge whenever you get a chance, @ErikBjare.

@ErikBjare ErikBjare merged commit a2eb69d into ActivityWatch:master Jul 5, 2026
16 checks passed
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

2 participants