#1070286 pipx: The ‘list’ command falsely claims “nothing has been installed with pipx 😴”

Package:
pipx
Source:
pipx
Submitter:
Manny
Date:
2024-05-03 18:33:02 UTC
Severity:
normal
Tags:
#1070286#5
Date:
2024-05-03 09:47:23 UTC
From:
To:
The argostranslate app was installed successfully by root as a
system-wide multi-user app as follows:

===8<----------------------------------------
  $ PIPX_HOME=${prefix:-/opt/}/pipx PIPX_BIN_DIR=${prefix:-/usr/local}/bin pipx install --verbose argostranslate

  pipx >(setup:757): pipx version is 1.1.0
  pipx >(setup:758): Default python interpreter is '/usr/bin/python3'
  pipx >(package_name_from_spec:323): Determined package name: argostranslate
  pipx >(package_name_from_spec:324): Package name determined in 0.0s
  creating virtual environment...
  pipx >(run_subprocess:173): running /usr/bin/python3 -m venv --without-pip /opt/pipx/venvs/argostranslate
  pipx >(run_subprocess:173): running /opt/pipx/venvs/argostranslate/bin/python -c import sysconfig; print(sysconfig.get_path('purelib'))
  pipx >(run_subprocess:173): running /opt/pipx/shared/bin/python -c import sysconfig; print(sysconfig.get_path('purelib'))
  pipx >(run_subprocess:173): running /opt/pipx/venvs/argostranslate/bin/python --version
  pipx >(_parsed_package_to_package_or_url:128): cleaned package spec: argostranslate
  installing argostranslate...
  pipx >(run_subprocess:173): running /opt/pipx/venvs/argostranslate/bin/python -m pip install argostranslate
  pipx >(run_subprocess:173): running <fetch_info_in_venv commands>
  pipx >(get_venv_metadata_for_package:303): get_venv_metadata_for_package: 2081ms
  pipx >(_parsed_package_to_package_or_url:128): cleaned package spec: argostranslate
  pipx >(needs_upgrade:69): Time since last upgrade of shared libs, in seconds: 6108. Upgrade will be run by pipx if greater than 2592000.
    installed package argostranslate 1.9.6, installed using Python 3.11.2
    These apps are now globally available
      - argos-translate
      - argospm
  pipx >(warn_if_not_on_path:410): ⚠️  Note: '/usr/local/bin' is not on your PATH environment variable. These apps will not be globally accessible until your PATH is
      updated. Run `pipx ensurepath` to automatically add it, or manually modify your PATH in your shell's config file (i.e. ~/.bashrc).
  done! ✨ 🌟 ✨
===8<----------------------------------------

Running “pipx list” both as root and as a user yields:

===8<----------------------------------------
  nothing has been installed with pipx 😴
===8<----------------------------------------

On the off chance that this is an environmental issue, running within the venv was also tested:

===8<----------------------------------------
  $ source /opt/pipx/venvs/argostranslate/bin/activate
  (argostranslate) 0 $ pipx list
  nothing has been installed with pipx 😴
===8<----------------------------------------

The argostranslate app runs fine. So it’s unclear why pipx would lose
track of it right away.

#1070286#10
Date:
2024-05-03 17:21:59 UTC
From:
To:
Hi Manny (2024.05.03_09:47:23_+0000)

...

Maybe something to do with setting a weird PIPX_HOME ?

Stefano

#1070286#15
Date:
2024-05-03 18:30:16 UTC
From:
To:
===8<----------------------------------------
$ PIPX_HOME=${prefix:-/opt/}/pipx PIPX_BIN_DIR=${prefix:-/usr/local}/bin pipx list
venvs are in /opt/pipx/venvs
apps are exposed on your $PATH at /usr/local/bin
   package argostranslate 1.9.6, installed using Python 3.11.2
    - argos-translate
    - argospm
===8<----------------------------------------

As user:
===8<----------------------------------------
$ PIPX_HOME=${prefix:-/opt/}/pipx PIPX_BIN_DIR=${prefix:-/usr/local}/bin pipx list
Traceback (most recent call last):
  File "/usr/lib/python3.11/logging/config.py", line 562, in configure
    handler = self.configure_handler(handlers[name])
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/logging/config.py", line 747, in configure_handler
    result = factory(**kwargs)
             ^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/logging/__init__.py", line 1181, in __init__
    StreamHandler.__init__(self, self._open())
                                 ^^^^^^^^^^^^
  File "/usr/lib/python3.11/logging/__init__.py", line 1213, in _open
    return open_func(self.baseFilename, self.mode,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
PermissionError: [Errno 13] Permission denied: '/opt/pipx/logs/cmd_2024-05-03_20.14.46.log'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/bin/pipx", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/usr/lib/python3/dist-packages/pipx/main.py", line 814, in cli
    setup(parsed_pipx_args)
  File "/usr/lib/python3/dist-packages/pipx/main.py", line 753, in setup
    setup_logging("verbose" in args and args.verbose)
  File "/usr/lib/python3/dist-packages/pipx/main.py", line 745, in setup_logging
    logging.config.dictConfig(logging_config)
  File "/usr/lib/python3.11/logging/config.py", line 812, in dictConfig
    dictConfigClass(config).configure()
  File "/usr/lib/python3.11/logging/config.py", line 569, in configure
    raise ValueError('Unable to configure handler '
ValueError: Unable to configure handler 'file'
===8<----------------------------------------

Which is discussed here:

https://github.com/pypa/pipx/issues/754#issuecomment-1181082995

I granted read access to /opt/pipx/logs/ for users and it made no
difference. I’ll just have to use root to list pkgs and call it good
enough for me. But certainly it’s a bug for pipx to crash and give a
stack dump. In the very least it should give a specific user-readable
error msg.