diff --git a/src/pipx/commands/reinstall.py b/src/pipx/commands/reinstall.py index 2bd1a2a39b..6f3cc43ed5 100644 --- a/src/pipx/commands/reinstall.py +++ b/src/pipx/commands/reinstall.py @@ -120,7 +120,7 @@ def reinstall_all( if venv_dir.name in skip: continue try: - package_exit = reinstall( + reinstall( venv_dir=venv_dir, local_bin_dir=local_bin_dir, local_man_dir=local_man_dir, @@ -134,8 +134,6 @@ def reinstall_all( failed.append(venv_dir.name) else: first_reinstall = False - if package_exit != 0: - failed.append(venv_dir.name) if len(failed) > 0: raise PipxError(f"The following package(s) failed to reinstall: {', '.join(failed)}") # Any failure to install will raise PipxError, otherwise success diff --git a/src/pipx/commands/upgrade.py b/src/pipx/commands/upgrade.py index 98049eab53..c5e2b49b1b 100644 --- a/src/pipx/commands/upgrade.py +++ b/src/pipx/commands/upgrade.py @@ -1,5 +1,6 @@ import logging import os +import sys from pathlib import Path from typing import Dict, List, Optional, Sequence @@ -220,15 +221,16 @@ def upgrade_all( python_flag_passed: bool = False, ) -> ExitCode: """Returns pipx exit code.""" - venv_error = False - venvs_upgraded = 0 + failed: List[str] = [] + upgraded: List[str] = [] + for venv_dir in venv_container.iter_venv_dirs(): venv = Venv(venv_dir, verbose=verbose) venv.check_upgrade_shared_libs(pip_args=pip_args, verbose=verbose) if venv_dir.name in skip or "--editable" in venv.pipx_metadata.main_package.pip_args: continue try: - venvs_upgraded += _upgrade_venv( + _upgrade_venv( venv_dir, venv.pipx_metadata.main_package.pip_args, verbose=verbose, @@ -237,18 +239,14 @@ def upgrade_all( force=force, python_flag_passed=python_flag_passed, ) - except PipxError as e: - venv_error = True - logger.error(f"Error encountered when upgrading {venv_dir.name}:") - logger.error(f"{e}\n") - - if venvs_upgraded == 0: + print(e, file=sys.stderr) + failed.append(venv_dir.name) + else: + upgraded.append(venv_dir.name) + if len(upgraded) == 0: print(f"Versions did not change after running 'pipx upgrade' for each package {sleep}") - if venv_error: - raise PipxError( - "\nSome packages encountered errors during upgrade.\n" " See specific error messages above.", - wrap_message=False, - ) - + if len(failed) > 0: + raise PipxError(f"The following package(s) failed to upgrade: {','.join(failed)}") + # Any failure to install will raise PipxError, otherwise success return EXIT_CODE_OK