pypa / pipx

Install and Run Python Applications in Isolated Environments
https://pipx.pypa.io
MIT License
10.01k stars 404 forks source link

`pipx install --global` partially installs in `~/.local` #1475

Closed viscruocco closed 1 month ago

viscruocco commented 1 month ago

Describe the bug

When executing pipx install --global:

How to reproduce

$ docker run -it --rm python:3 bash
$$ pip install git+https://github.com/pypa/pipx.git
$$ pipx install --global cowsay
$$ which cowsay
/usr/local/bin/cowsay   # --> good
$$ ls /opt/pipx/venvs
cowsay                  # --> good
$$ ls /opt/pipx/
venvs                   # --> bad: bin and share should be here
$$ ls ~/.local/
bin  share  state       # --> bad: bin and share should NOT exist here; good: state/pipx/log is ok here
$ ls ~/.local/bin/
                        # --> bad: ~/.local/share/bin is empty
$ ls ~/.local/share/
man  pipx               # --> bad: ~/.local/share/pipx is actually created and used here

Expected behavior

$ docker run -it --rm python:3 bash
$$ pip install git+https://github.com/pypa/pipx.git
$$ pipx install --global cowsay
$$ which cowsay
/usr/local/bin/cowsay
$$ ls /opt/pipx/venvs
cowsay
$$ ls /opt/pipx/
bin  share  venvs
$$ ls ~/.local/
state
viscruocco commented 1 month ago

After some consideration I noticed that the log files should also be written into the global directories instead of ~/.local. As mentioned above ~/.local might not be writeable after all. Since there is no configuration variable for the log directory it would be especially problematic to place it outside of PIPX_HOME. (The same goes for the cache and trash directories.)

Denney-tech commented 1 month ago

Encountering similar bug/behavior with pipx --global upgrade <spec> --install, but it does install apps to ~/.local/bin/ even though they are already found in /usr/local/bin.

viscruocco commented 1 month ago

[...] pipx --global upgrade <spec> --install [...]

That's most likely related to https://github.com/pypa/pipx/issues/1443. Try putting --global after upgrade instead: pipx upgrade --global <spec> --install