From 92ad6107e12c59f0fa2edcd9055eca22e257c6fd Mon Sep 17 00:00:00 2001 From: Chris Smart Date: Wed, 24 Aug 2016 18:28:13 +1000 Subject: [PATCH] Tell existing shell about upgraded pip When using pip to upgrade itself on a system which already has it installed, the existing shell does not quite know about the new version. Even though the 'which' command knows about the new package, running 'pip' will actually execute the previous version. This means any scripts which require a new version of pip will not work as expected. This is related to 07123ebeaa39 "Fix wrong version of pip used in bootstrap" where the wrong version of pip was being used (although it was fixed in a different manner there due to the use of virtualenv). Note that this does not affect systems which do not already have pip installed, nor instances which run a new shell after upgrading pip. This can be seen if one uses apt-get to install pip on Ubuntu 14.04 and then uses pip to upgrade itself. For example: root@ubuntu:~# apt-get install python-pip root@ubuntu:~# which pip /usr/bin/pip root@ubuntu:~# pip --version pip 1.5.4 from /usr/lib/python2.7/dist-packages (python 2.7) root@ubuntu:~# pip install --upgrade pip root@ubuntu:~# which pip /usr/local/bin/pip root@ubuntu:~# pip --version pip 1.5.4 from /usr/lib/python2.7/dist-packages (python 2.7) root@ubuntu:~# hash -r pip root@ubuntu:~# pip --version pip 8.1.2 from /usr/local/lib/python2.7/dist-packages (python 2.7) This patch forces the shell to re-hash the location of pip after an upgrade. Change-Id: Ifd9182ec862d6f8e9de2f0e4dc7778fbd46bb594 --- scripts/scripts-library.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/scripts-library.sh b/scripts/scripts-library.sh index 11a559ce4e..aa0fd22b6a 100755 --- a/scripts/scripts-library.sh +++ b/scripts/scripts-library.sh @@ -217,6 +217,9 @@ function get_pip { # been updated at this point to include any newer pip packages. pip install --upgrade ${PIP_INSTALL_OPTIONS} || pip install --upgrade --isolated ${PIP_INSTALL_OPTIONS} + # Ensure that our shell knows about the new pip + hash -r pip + # when pip is not installed, install it else