pipx: $PIPX_HOME on macOS since release 1.3.0 breaks many scripts

It appears that since release 1.3.0, when installing pipx on macOS Ventura, it chooses to set $PIPX_HOME to ~/Library/Application Support/pipx, which creates a problem for scripts like awscli where the directory forms part of the shebang, because shebangs are not allowed to have spaces in it.

As recent as release 1.2.1, $PIPX_HOME on macOS Ventura is set to be ~/.local/pipx which doesn’t cause problems.

How to reproduce

I was using Python 3.8 installed using pyenv.

pip install pipx==1.3.0
pipx environment 

It prints the below: Screenshot 2024-01-08 at 18 43 56

Expected behavior

$PIPX_HOME should be /Users/test3/.local/pipx

About this issue

  • Original URL
  • State: open
  • Created 6 months ago
  • Comments: 16 (15 by maintainers)

Most upvoted comments

Today I learned that the shell I use actually supports spaces in pathnames in shebangs. Since it uses shlex to parse the shebang line, it works if one puts quotes around the interpreter. In https://github.com/xonsh/xonsh/discussions/5315, I provide more details and I’m seeking to find places to make a proper solution more widely available.

On other Unix systems the behaviour will be kept.

That’s too bad, because other Unix users are affected too, except that they avoid having spaces in their directory names and perpetuate the expectation that spaces are invalid.

This is about making sure the default pipx behavior is robust. We can’t really prevent users from setting their pipx home to a path containing spaces. I may extend my PR to print a warning if a space is found in the pipx home.

I don’t think this project is the right place to discuss whether spaces should or should not be allowed in shebangs.

It is currently being worked on reverting the platformdirs usage for pipx paths on macOS in #1297, since several issues with it have been reported. On other Unix systems the behaviour will be kept.

Besides, probably this issue should be reported at the platformdirs location, too.

Nothing besides what was already discussed in that issue 🤔