Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pipx ensurepath --global doesn't. Ensure paths globally that is! #1452

Open
bernd-wechner opened this issue Jun 15, 2024 · 0 comments
Open

Comments

@bernd-wechner
Copy link

Up front pipx rocks! I mean, it should really be part of the standard pip to support isolated system installs given how widespread Python is now and used in system utilities and the package version conflict issues that threatens on system installs.

And pipx install --global seems to do what is needed (though sudo pipx install is IMHO broken and should do the same thing, install globally but instead installs for the root user).

Alas the documentation (@ https://pipx.pypa.io/stable/installation/) suggests:

sudo pipx ensurepath --global # optional to allow pipx actions in global scope. See "Global installation" section below.

and sudo pipx ensurepath --global does no such thing. This is very broken.

Cautious as I am, and the doc being rather sparse in this area stating only:

--global Perform action globally for all users.

not sharing how that is done, and discovering pip relies heavily on userpath which does not share what it does (works like a magic box) and so I filed an issue there too: ofek/userpath#59, I cloned pipx and single stepped:

pipx ensurepath --global --force

to make sure I understood right (as my code review as not encouraging, but the levels of indirection and abstraction certainly warrant neutering userpath by commenting out the file writes in put and logging its actions, but I was right, it's broken).

Here's what

sudo pipx ensurepath --global

claims to do and is recommended on the basis of:

allow pipx actions in global scope.

But what it does is it adds PATH updates to two files only being ~/.bashrc and ~/.profile being:

# Created by pipx on <date>
export PATH="$PATH:/usr/local/bin"
# Created by pipx on <date>
export PATH="$PATH:/home/bernd/.local/bin"

The duplicity aside (it could be a little smarter and do this in one line when needed, but then pipx has delegated all that to userpath which is still evolving too) neither of the files written to deliver on the promise of allowing pipx actions in global scope.

No way that Is slice does this deliver. Neither in global scope interpreted to mean "for all users" nor in global scope interpreted to mean in by adding the global bin home (/opt/pipx by default: https://github.com/pypa/pipx/blob/main/src/pipx/paths.py).

I would argue that (or I would expect that) sudo pipx ensurepath --global adds the global bin dir (defaulting to /usr/local/bin) to the global path (in /etc/environment).

Not a crisis, but given the blind delegation to userpath that does magic box changes (as per issue above), I have insufficient faith in ensurepath to be recommending it to anyone and would recommend ensuring paths manually at present.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant