question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Option to install package globally for multi-user access

See original GitHub issue

Hi All, not sure if this qualifies as a feature request, or if it’s already possible and just needs to be documented?

pipx by default installs its virtualenvs in a folder inside the user’s home directory (ie ~/.local/pipx/venvs/), and installs the entrypoint binaries for those packages/virtualenvs in the user’s personal path (ie ~/.local/bin).

Is it possible to install packages with pipx such that they are globally executable by all users on a system (ie install entrypoint binaries in /usr/local/bin, install virtualenvs somewhere that all users can access them?

How would this feature be useful?

Having this ability would make pipx a prime candidate for people looking to deploy python software in multi-user environments. Without this ability, pipx is not usable at all in such situations

Describe the solution you’d like

Ideally, some kind of --shared or --global flag would be the most straightforward solution, but even something like an optional environment variable would be nice

Ex: sudo pipx install --global cowsay

Describe alternatives you’ve considered

There are currently no alternatives / workarounds that I’m aware of. I cannot find anything about this in the documentation, the github issues, or on the web

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:4
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

4reactions
eodecommented, Jul 15, 2022

I definitely would like to have a --global option for pipx. I’ve put some thought into how this could be done (fairly) reasonably:

  • New environment vars:
    • PIPX_GLOBAL_HOME
    • PIPX_GLOBAL_BIN_DIR
  • Normal ‘local’ usage is treated just as it is now (including when using as root) except:
    • If the global directory is present, global info is included in output
    • --local can be specified to exclude global info
    • install output changes to “These apps are now locally available”
  • With --global:
    • Use PIPX_GLOBAL_* env vars.
      • Use PIPX_GLOBAL_HOME, or distro-specific global install dir, or /opt/pipx/ (failover)
      • Use PIPX_GLOBAL_BIN_DIR, the distro-specific global bin dir, or /usr/local/bin/ (failover)
    • Treat the global dir as though we have write permission – user should have elevated permissions using sudo
  • Encourage proper usage via cli
    • Wherever a command looks like it might be mistaken, issue a warning / suggestion
      • "Writing into /home/someuser/.local/pipx, owned by someuser, as root. Did you mean to use --global?
      • "Installing foopkg locally for the user root. Did you mean to use --global?
  • JSON output includes “global venvs” key as a sibling to the “venvs” key.
  • Release on a major version change, because it introduces a new concept and changes the output.

Example usage:

$ pipx list
global venvs are in /opt/pipx/venvs
apps are exposed on your $PATH at /usr/local/bin
   package poetry 1.1.0, installed using Python 3.10.4
    - poetry
local venvs are in /home/someuser/.local/pipx/venvs
apps are exposed on your $PATH at /home/someuser/.local/bin
   package doit 0.36.0, installed using Python 3.10.4
    - doit
   package poetry 1.1.14, installed using Python 3.10.4
    - poetry
$ pipx list --local
local venvs are in /home/someuser/.local/pipx/venvs
apps are exposed on your $PATH at /home/someuser/.local/bin
   package doit 0.36.0, installed using Python 3.10.4
    - doit
   package poetry 1.1.14, installed using Python 3.10.4
    - poetry
$ sudo pipx install --global foocmd
  installed package foocmd 0.9.0, installed using Python 3.10.4
  These apps are now globally available
    - foo
    - foolog
done! ✨ 🌟 ✨
$ pipx install foocmd
  installed package foocmd 0.9.0, installed using Python 3.10.4
  These apps are now locally available
    - foo
    - foolog
done! ✨ 🌟 ✨

All-in-all, that’s a fair amount of work, but not a ton of work to make the change, but I think that all of that work would be necessary to fully implement this change.

Alternately, --global could just do an override of the existing PIPX_HOME and PIPX_BIN_DIR env-vars, using distro-specific settings. This just means that sudo pipx list --global is required to read global items. I just like the UX of pipx list showing global and local installs.

1reaction
carlolarscommented, Jul 14, 2022

I think it would be nice to have a switch for global install. For example when using doas instead of sudo I had to first do doas su to run the pipx command with the environment variables as root. It would be a lot easier to just do doas pipx install --global cowsay.

Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js - Making Global NPM packages available to all users ...
Open an administrator level command prompt · Note the current global prefix: npm prefix -g · Set the global prefix to the CI...
Read more >
Installing for multiple users - Anaconda Documentation
Multi-user Anaconda installation on Linux​​ This is another option for all-user installation. It installs Anaconda at C:\Anaconda , which is not a protected ......
Read more >
Downloading and installing packages globally - npm Docs
Installing a package globally allows you to use the code in the package as a set of tools on your local computer. To...
Read more >
Ways to share an Access desktop database - Microsoft Support
Ways of sharing a Microsoft Access database. ... In this article, we'll take a look at the options available, the benefits of each...
Read more >
Administering a multi-user conda installation
This system-level configuration file will override any user-level configuration files installed by the user. Each user accesses the central conda installation, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found