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

HIGH: pipx install --global order broken in 1.6.0 #1443

Open
wdoekes opened this issue Jun 5, 2024 · 7 comments
Open

HIGH: pipx install --global order broken in 1.6.0 #1443

wdoekes opened this issue Jun 5, 2024 · 7 comments

Comments

@wdoekes
Copy link

wdoekes commented Jun 5, 2024

Describe the bug

Doing pipx install --global behaves differently from pipx --global install. The latter command does not do global but local.

How to reproduce

root@05515ef1bff7:/# pipx --global install dutree
  installed package dutree 1.8, installed using Python 3.9.2
  These apps are now globally available
    - dutree
⚠️  Note: '/root/.local/bin' is not on your PATH environment variable. These apps will not be globally accessible until your PATH is updated. Run `pipx ensurepath` to automatically
    add it, or manually modify your PATH in your shell's config file (e.g. ~/.bashrc).
done! ✨ 🌟 ✨
root@05515ef1bff7:/# which dutree
root@05515ef1bff7:/# ls /root/.local/bin
dutree

^- not global

root@05515ef1bff7:/# pipx uninstall dutree
uninstalled dutree! ✨ 🌟 ✨
root@05515ef1bff7:/# pipx install --global dutree
  installed package dutree 1.8, installed using Python 3.9.2
  These apps are now globally available
    - dutree
done! ✨ 🌟 ✨
root@05515ef1bff7:/# which dutree
/usr/local/bin/dutree

^- yes, global

root@05515ef1bff7:/# pipx --version
1.6.0

Expected behavior

Both install --global and --global install should install in the same place: /usr/local/bin.

Cause?

Likely the code from #1397 has something to do with this.

1.5 works fine:

root@05515ef1bff7:/# pipx uninstall --global dutree
uninstalled dutree! ✨ 🌟 ✨
root@05515ef1bff7:/# pip3 install pipx==1.5.0
Collecting pipx==1.5.0
  Downloading pipx-1.5.0-py3-none-any.whl (72 kB)
     |████████████████████████████████| 72 kB 653 kB/s 
...
Successfully installed pipx-1.5.0
root@05515ef1bff7:/# pipx --global install dutree
  installed package dutree 1.8, installed using Python 3.9.2
  These apps are now globally available
    - dutree
done! ✨ 🌟 ✨
root@05515ef1bff7:/# which dutree
/usr/local/bin/dutree

In 1.5 it complains when doing things "the new way":

root@05515ef1bff7:/# pipx install --global dutree
usage: pipx [-h] [--quiet] [--verbose] [--global] [--version]
            {install,uninject,inject,upgrade,upgrade-all,uninstall,uninstall-all,reinstall,reinstall-all,list,interpreter,run,runpip,ensurepath,environment,completions} ...
pipx: error: unrecognized arguments: --global

So, the only order has been --global install and something in 1.6.0 severely broke it.

@dukecat0
Copy link
Member

dukecat0 commented Jun 5, 2024

Seems related to #1282.

@wdoekes
Copy link
Author

wdoekes commented Jun 5, 2024

There is this code:

    parser = argparse.ArgumentParser(
        prog=prog_name(),
        formatter_class=LineWrapRawTextHelpFormatter,
        description=PIPX_DESCRIPTION,
        parents=[shared_parser],
    )

It enables/allows --global etc. before the install command. But it's a separate parser and values are not available at parser.parse_args() because they are overwritten by the second usage of shared_parser.

Easiest workaround is to disallow the shared_parser values. At least then the breakage is obvious:

    parser = argparse.ArgumentParser(
        prog=prog_name(),
        formatter_class=LineWrapRawTextHelpFormatter,
        description=PIPX_DESCRIPTION,
        #REMOVEME# `parents=[shared_parser],
    )

An alternative might be to rename the dest (from global_is_global to is_global) before using it as second shared_parser and then checking a combination of global_is_global and is_global. But that feels hackish.

@michelzanini
Copy link

This is a major bug to me. It breaks backwards compatibility.

@mpickering
Copy link

I also ran into this issue.

@metametadata
Copy link

This problem has broken our CI pipelines.

@jradxl
Copy link

jradxl commented Sep 1, 2024

I've just found this with version 1.7.1 downloaded from your release page.
Very confusing for 24 hours!
In your Unit tests it's got to work for Uninstall too
and I assume, "pipx list", "pipx --global list" and "pipx list --global" all need to provide correct information so any user knows what's where and back out any remaining errors

@gaby
Copy link

gaby commented Oct 8, 2024

Any progress on this?

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

Successfully merging a pull request may close this issue.

7 participants