Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/1611.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`pipx reinstall`: An exception will now be raised if package is pinned.
3 changes: 3 additions & 0 deletions src/pipx/commands/reinstall.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ def reinstall(
else:
package_or_url = venv.main_package_name

if venv.pipx_metadata.main_package.pinned:
raise PipxError(f"{error} Package {venv_dir} is pinned. Run `pipx unpin {venv_dir.name}` to unpin it first.")

uninstall(venv_dir, local_bin_dir, local_man_dir, verbose)

# in case legacy original dir name
Expand Down
13 changes: 13 additions & 0 deletions tests/test_reinstall.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,16 @@ def test_reinstall_with_path(pipx_temp_env, capsys, tmp_path):
captured = capsys.readouterr()

assert "Expected the name of an installed package" in captured.err.replace("\n", " ")


def test_reinstall_pinned_package(pipx_temp_env, capsys):
assert not run_pipx_cli(["install", "black"])
assert not run_pipx_cli(["pin", "black"])
assert run_pipx_cli(["reinstall", "black"])
captured = capsys.readouterr()
assert "pinned" in captured.err

assert not run_pipx_cli(["unpin", "black"])
assert not run_pipx_cli(["reinstall", "black"])
captured = capsys.readouterr()
assert "installed package black" in captured.out
Loading