pip: pip install should exit with non-zero exit code when not given enough arguments

  • Pip version: 9.0.1
  • Python version: 3.6
  • Operating system: Mac OS X 10.12 / Arch Linux

Description:

$ pip install -U
You must give at least one requirement to install (see "pip help install")
$ echo $?
0

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 6
  • Comments: 16 (4 by maintainers)

Most upvoted comments

#2720 and #4210 are now fixed.

This seems to work fine now in pip version 10.0.0:

$ pip2 --version
pip 10.0.0 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)

$ pip2 install -U
ERROR: You must give at least one requirement to install (see "pip help install")

$ echo $?
1

@vmalloc Ready to close this one? 😊

@vmalloc just to be clear: I completey agree with you. It just did not bite me yet in the case of pip, but fixing this for 10.0 would definitely be appreciated.

While I agree this is a corner case, I think all command-line tools should return a nonzero exit status if they failed to fulfill the user’s request or did not receive enough information to do so. This is normal behavior for the vast majority of command-line tools nowadays, especially in UNIX-based environments.

We hit this by accident - since we run pip automatically and due to another bug did not pass enough arguments to it, and the command succeeded, hiding our real issue - so this is not an imaginary scenario like spacebar heating…

@obestwalter oh sorry - so I really did misunderstand you. My bad.

This is not all. I just tried:

$ pip
$ pip install

… they also print an error or help message but exit with 0 - on the other hand

$ pip search
$ pip show

… exit with 1.