Skip to content

Commit

Permalink
Fix error log overwrite for "-all" batch operations. (#1365)
Browse files Browse the repository at this point in the history
  • Loading branch information
huxuan authored Apr 25, 2024
1 parent 32bad16 commit 5d610e5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.d/1132.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix error log overwrite for "-all" batch operations.
2 changes: 1 addition & 1 deletion src/pipx/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ def subprocess_post_check_handle_pip_error(
if paths.ctx.log_file is None:
raise PipxError("Pipx internal error: No log_file present.")
pip_error_file = paths.ctx.log_file.parent / (paths.ctx.log_file.stem + "_pip_errors.log")
with pip_error_file.open("w", encoding="utf-8") as pip_error_fh:
with pip_error_file.open("a", encoding="utf-8") as pip_error_fh:
print("PIP STDOUT", file=pip_error_fh)
print("----------", file=pip_error_fh)
if completed_process.stdout is not None:
Expand Down
6 changes: 6 additions & 0 deletions tests/test_install_all.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from pathlib import Path

from helpers import run_pipx_cli
from pipx import paths


def test_install_all(pipx_temp_env, tmp_path, capsys):
Expand Down Expand Up @@ -28,3 +29,8 @@ def test_install_all_multiple_errors(pipx_temp_env, root, capsys):
captured = capsys.readouterr()
assert "The following package(s) failed to install: dotenv, weblate" in captured.err
assert f"No packages installed after running 'pipx install-all {pipx_metadata_path}'" in captured.out
if paths.ctx.log_file:
with open(paths.ctx.log_file.parent / (paths.ctx.log_file.stem + "_pip_errors.log")) as log_fh:
log_contents = log_fh.read()
assert "dotenv" in log_contents
assert "weblate" in log_contents

0 comments on commit 5d610e5

Please sign in to comment.