pip.install: fails in v2015.2.0rc1 when the package is already installed (pip v1.0)
In #19001 salt/states/pip_state.py code was changed so that pip install would be run even if there is nothing to install.
With pip v1.0 pip install returns 1 when run without any arguments:
$ pip install
You must give at least one requirement to install (see "pip help install")
Storing complete log in /home/vagrant/.pip/pip.log
$ echo $?
1
With pip2 the message is the same but it returns 0:
$ pip install
You must give at least one requirement to install (see "pip help install")
$ echo $?
0
state.sls:
python-gnupg:
pip.installed:
- require:
- pkg: python-pip
python-pip:
pkg.installed
Result:
----------
ID: python-pip
Function: pkg.installed
Name: python-pip
Result: True
Comment: The following packages were installed/updated: python-pip.
Started: 14:52:19.481977
Duration: 7788.201 ms
Changes:
----------
python-distribute:
----------
new:
1
old:
python-pip:
----------
new:
1.0-1build1
old:
python-setuptools:
----------
new:
0.6.24-1ubuntu1
old:
----------
ID: python-gnupg
Function: pip.installed
Name: python-gnupg
Result: False
Comment: Python package python-gnupg was already installed
Failed to install packages: . Error: You must give at least one requirement to install (see "pip help install")
Storing complete log in /home/vagrant/.pip/pip.log
Started: 14:52:27.273236
Duration: 220.27 ms
Changes:
----------
Adding - ignore_installed: True to the pip state will make the package install, but then it is installed during every highstate call.
@kitsemets, thanks for the report.
+1
+1
+1
+1
+1
+1 in 2015.5.3
+1 with @yanatan16 in 2015.5.3
This is preventing us from upgrading to 2015.5. Is there a workaround to install pip v2 on Ubuntu 12.04 by any chance?
You can try salt ubuntu-minion cmd.run 'pip install --upgrade pip'.
+1 this is a hugely annoying bug.
Upgrading pip worked. I am just wondering if that is going to cause other problems. And of course pip2 would have to be installed on new servers as well...
@jacobhammons - 2015.8
+1
+1, this makes salt stack painful to use with the version of pip installed by default on Ubuntu 12.04.
Hi All - I've submitted #27996 to fix this bug. It passed very well with all of my tests, but if y'all could give it a try and make sure this is resolved for you, that would be swell.
Since I didn't hear back from anyone here, and I am fairly certain this is fixed, I am going to close this. The fix will be available in 2015.8.2. If this pops up again, please let us know and we'll take another look. Thanks everyone!
Hi,
I am planning our upgrade to salt "2015.8.3+ds-1" and I am getting this issue, sort of. I am not getting an error in the highstate summary but I am seeing:
[INFO ] Executing command ['/usr/bin/pip', 'install', '--index-url', 'http://apt.think.vpc:4040/simple', '--extra-index-url', 'http://apt02.think.vpc:4040/simple'] in directory '/root' [ERROR ] Command ['/usr/bin/pip', 'install', '--index-url', 'http://apt.think.vpc:4040/simple', '--extra-index-url', 'http://apt02.think.vpc:4040/simple'] failed with return code: 1 [ERROR ] stdout: You must give at least one requirement to install (see "pip help install") Storing complete log in /root/.pip/pip.log [ERROR ] retcode: 1
If a pip package is missing, it installs without any errors.
Is this how your bug fix is supposed to work? Some errors in the output but no errors in the salt output?
Thanks.
Hi there,
I've just run into this issue today and from what I read above, it should have been fixed.
My version of both salt-master and salt-minion are: salt-master 2017.7.3 (Nitrogen) and salt-minion 2017.7.3 (Nitrogen)
I have the below states:
some_virtual_env:
virtualenv.managed:
- name: /opt/python-virtualenvs/some_virtual_env
- cwd: /opt/python-virtualenvs
- user: root
#- runas: root
- python: /opt/python3.6.5/bin/python3.6
- system_site_packages: False
- require:
- pkg: python-pip
- file: /opt/python-virtualenvs
- pip: virtualenv
install_beautifulsoup4_module:
pip.installed:
- name: beautifulsoup4
- bin_env: /opt/python-virtualenvs/some_virtual_env
- require:
- pkg: python-pip
- virtualenv: some_virtual_env
python-pip:
pkg.installed
virtualenv:
pip.installed:
- require:
#- pkg: python-pip
- pkg: pip
/opt/python-virtualenvs:
file.directory:
- user: root
- group: root
- mode: 775
- require:
- pkg: python-pip
So, when i execute state.highstate from the master the first time, everything works fine. The install_beautifulsoup4_module state above works good. However, if i run state.highstate a second time, it fails with the below:
----------
ID: install_beautifulsoup4_module
Function: pip.installed
Name: beautifulsoup4
Result: False
Comment: Python package beautifulsoup4 was already installed
Failed to install packages: . Error: ERROR: You must give at le
ast one requirement to install (see "pip help install")
Started: 14:27:48.932662
Duration: 1552.199 ms
Changes:
----------
This looked really strange to me as it detects that the package was already installed but at the same time throws the error. So, i decided to run salt-call state.sls from the minion instead with the -l debug flag, and i got the below:
[INFO ] Running state [beautifulsoup4] at time 13:59:52.257317 [194/20680]
[INFO ] Executing state pip.installed for [beautifulsoup4]
[DEBUG ] Installed pip version: 9.0.1
[INFO ] Executing command '/opt/python-virtualenvs/some_virtual_env/bin/pip --version' in directory '/root'
[DEBUG ] output: pip 10.0.1 from /opt/python-virtualenvs/some_virtual_env/lib/python3.6/site-packages/pip (python 3.6)
[INFO ] Executing command ['/opt/python-virtualenvs/some_virtual_env/bin/pip', 'freeze', '--all'] in directory '/root'
[DEBUG ] stdout: asn1crypto==0.24.0
beautifulsoup4==4.6.0
boto3==1.7.10
botocore==1.10.10
certifi==2018.4.16
cffi==1.11.5
chardet==3.0.4
configparser==3.5.0
cryptography==2.2.2
docutils==0.14
idna==2.6
jmespath==0.9.3
ntlm-auth==1.1.0
pip==10.0.1
pycparser==2.18
python-dateutil==2.7.2
requests==2.18.4
requests-ntlm==1.1.0
s3transfer==0.1.13
setuptools==39.1.0
six==1.11.0
urllib3==1.22
wheel==0.31.0
[DEBUG ] CLEANUP_REQUIREMENTS: []
[DEBUG ] TRY BLOCK: end of pip.install -- cmd: ['/opt/python-virtualenvs/some_virtual_env/bin/pip', 'install'], cmd_kwargs: {'runas': None, 'use_vt': Fal
se, 'saltenv': 'base', 'env': {'VIRTUAL_ENV': '/opt/python-virtualenvs/some_virtual_env'}}
[INFO ] Executing command ['/opt/python-virtualenvs/some_virtual_env/bin/pip', 'install'] in directory '/root'
[ERROR ] Command '['/opt/python-virtualenvs/some_virtual_env/bin/pip', 'install']' failed with return code: 1
[ERROR ] stderr: ERROR: You must give at least one requirement to install (see "pip help install")
[ERROR ] retcode: 1
[ERROR ] Python package beautifulsoup4 was already installed
Failed to install packages: . Error: ERROR: You must give at least one requirement to install (see "pip help install")
[INFO ] Completed state [beautifulsoup4] at time 13:59:53.773396 duration_in_ms=1516.079
Not much more information than the error before, but there's one thing here. The error Error: ERROR: You must give at least one requirement to install (see "pip help install") usually happens when you call pip install without any package name to install.
And looking at the line [INFO ] Executing command ['/opt/python-virtualenvs/some_virtual_env/bin/pip', 'install'] in directory '/root' from the debug above, seems like pip install is being indeed run without any package name and therefore it complains with the above error.
Is there a bug here where state pip.installed will not pass a package name to pip if it detects that the package that is trying to install is already installed? Because the first time works fine. That's what i'm getting from the error above.
Was there any solution to this error? It's still a problem with Salt Nitrogen that i'm running.
Thanks,
One more thing - if i add ignore_installed: True to the pip.installed state, it works but then it gets executed in every state.highstate which is not ideal. That's the only workaround i've found so far. Not an ideal one, though.