pipx icon indicating copy to clipboard operation
pipx copied to clipboard

Pipx ensurepath sets environment in the active shell, not other shells

Open TeaDrinkingProgrammer opened this issue 1 year ago • 0 comments

Describe the bug

When running pipx ensurepath, it sets the variable in the shells "rc" file. This causes issues when you run the command in one shell, but use another one later or use /bin/sh. A practical example of where this becomes an issue is docker: it uses /bin/sh to run commands, so the pipx ensurepath command sets the bashrc file and the path is still not set for subsequent Docker commands. This means that pipx ensurepath is essentially broken in Docker.

How to reproduce

  1. Run `/bin/sh pipx ensurepath
  2. Try to run an application with Pipx
  3. The shell returns command not found

Expected behavior

I know that there is a debate about what the correct place is to set environment variables, but I think we can all agree that ./~bashrc is not one of those. I personally use /etc/environment, but I leave it up to the maintainers' discretion to pick an option.

Edit: The issue seems that the userpath library has chosen to add to shell rc files, so it seems that wether to add to the RC file or not is not as clearcut as I thought. If you choose to leave the current behaviour, I think it would be a good idea to add the caveats of ensurepath in the documentation (and maybe add that you need to run the command at all in the installation guide).

TeaDrinkingProgrammer avatar Mar 13 '24 11:03 TeaDrinkingProgrammer