Skip to content

Add --dry-run flag to pipx ensurepath#1842

Open
somaz94 wants to merge 2 commits into
pypa:mainfrom
somaz94:feat/ensurepath-dry-run
Open

Add --dry-run flag to pipx ensurepath#1842
somaz94 wants to merge 2 commits into
pypa:mainfrom
somaz94:feat/ensurepath-dry-run

Conversation

@somaz94

@somaz94 somaz94 commented Jun 18, 2026

Copy link
Copy Markdown

Adds a --dry-run flag to pipx ensurepath that reports which directories
would be added to PATH without modifying PATH or any shell configuration
file, so users can preview the change before running it for real (closes #1014).

The flag threads a dry_run parameter through ensure_pipx_paths
ensure_path; in dry-run mode userpath.append/prepend are never called and
a "Would append/prepend ..." line plus a "no changes were made" footer are
printed instead.

  • ran the linter to address style issues (pre-commit run --all-files)
  • wrote descriptive pull request text
  • ensured there are test(s) validating the fix
  • added news fragment in changelog.d/ folder (feature)
  • updated/extended the documentation

Validation

  • New tests/test_ensurepath.py (4 tests — first test file for this command):
    asserts dry-run never calls userpath.append/prepend, never mutates config,
    and checks the footer + EXIT_CODE_OK.
  • ruff check + ruff format --check clean on all changed files.
  • End-to-end pipx ensurepath --dry-run --force prints Would append ... and
    the no-changes footer without touching PATH.

@somaz94 somaz94 marked this pull request as ready for review June 19, 2026 02:44
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.

Provide ensurepath with a check option or create an init command

1 participant