-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
_find_chocolatey() failes due to renaming of chocolatey.exe #64427
Comments
Hi there! Welcome to the Salt Community! Thank you for making your first contribution. We have a lengthy process for issues and PRs. Someone from the Core Team will follow up as soon as possible. In the meantime, here’s some information that may help as you continue your Salt journey.
There are lots of ways to get involved in our community. Every month, there are around a dozen opportunities to meet with other contributors and the Salt Core team and collaborate in real time. The best way to keep track is by subscribing to the Salt Community Events Calendar. |
I worked around for the moment with adding this lines: salt/modules/chocolatey.py (line 108 to 119)
|
I just did the following until the patch arrives: # Is chocolatey installed?
Chocolatey is installed without symlink:
file.exists:
- name: 'C:\ProgramData\chocolatey\choco.exe'
# Bootstrap Chocolatey package manager
Bootstrap Chocolatey:
module.run:
- chocolatey.bootstrap: []
- onfail:
- Chocolatey is installed without symlink
# Ensure there is a symlink from chocolatey.exe to choco.exe
Chocolatey is installed:
file.symlink:
- name: 'C:\ProgramData\chocolatey\chocolatey.exe'
- target: 'C:\ProgramData\chocolatey\choco.exe'
- require:
- Chocolatey is installed without symlink
|
@adrianschneider94 Good idea. But in my case chocolatey.upgraded search in %programdata%\chocolatey\bin\ for chocolatey.exe From chocolatey.py:
That is how it works for me:
|
@TimHiCe @adrianschneider94 great solution, this a clever workaround. I'd like to propose one additional enhancement, which is moving the
This prevents that state from always showing as a failure but accomplishes the same behavior. |
It seems related to breaking change from chocolatey In the end, the Salt module might need to adapt to both cases or have a different implementation depending on the installed version. |
From my code review every install-, update- etc. method is build on _find_chocolatey(). If this method find the right choco(latey).exe every think should be fine. That is what I have done in the linked pull request. By the way, another workaround could be setting an environment variable to install an older version (not testet by me): |
Description of Issue
State chocolatey.installed search for "chocolatey.exe" but Chocolatey has renamed it to "choco.exe"
Function: chocolatey.installed Result: False Comment: An exception occurred in this state: Traceback (most recent call last): File "salt\state.py", line 2276, in call ret = self.states[cdata["full"]]( File "salt\loader\lazy.py", line 149, in __call__ return self.loader.run(run_func, *args, **kwargs) File "salt\loader\lazy.py", line 1228, in run return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs) File "salt\loader\lazy.py", line 1243, in _run_as return _func_or_method(*args, **kwargs) File "salt\loader\lazy.py", line 1276, in wrapper return f(*args, **kwargs) File "C:\Program Files\Salt Project\salt\salt\salt\states\chocolatey.py", line 106, in installed pre_install = __salt__["chocolatey.list"](local_only=True) File "salt\loader\lazy.py", line 149, in __call__ return self.loader.run(run_func, *args, **kwargs) File "salt\loader\lazy.py", line 1228, in run return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs) File "salt\loader\lazy.py", line 1243, in _run_as return _func_or_method(*args, **kwargs) File "C:\Program Files\Salt Project\salt\salt\salt\modules\chocolatey.py", line 460, in list_ choc_path = _find_chocolatey() File "C:\Program Files\Salt Project\salt\salt\salt\modules\chocolatey.py", line 127, in _find_chocolatey raise CommandExecutionError(err) salt.exceptions.CommandExecutionError: Chocolatey not installed. Use chocolatey.bootstrap to install the Chocolatey package manager.
salt/modules/chocolatey.py (line 95 to 128)
Steps to Reproduce Issue
salt 'XXXXXX' chocolatey.bootstrap
salt 'XXXXXX' chocolatey.install 'notepadplusplus'
Versions Report
salt-call --versions-report
Salt Version:
Salt: 3005.1
Dependency Versions:
cffi: 1.14.6
cherrypy: 18.6.1
dateutil: 2.8.1
docker-py: Not Installed
gitdb: 4.0.7
gitpython: Not Installed
Jinja2: 3.1.0
libgit2: Not Installed
M2Crypto: Not Installed
Mako: 1.1.4
msgpack: 1.0.2
msgpack-pure: Not Installed
mysql-python: Not Installed
pycparser: 2.21
pycrypto: Not Installed
pycryptodome: 3.10.1
pygit2: Not Installed
Python: 3.8.16 (tags/v3.8.16:1e3d2d5, Dec 9 2022, 17:48:54) [MSC v.1916 64 bit (AMD64)]
python-gnupg: 0.4.8
PyYAML: 5.4.1
PyZMQ: 22.0.3
smmap: 4.0.0
timelib: 0.2.4
Tornado: 4.5.3
ZMQ: 4.3.4
System Versions:
dist:
locale: cp1252
machine: AMD64
release: 2019Server
system: Windows
version: 2019Server 10.0.17763 SP0 Multiprocessor Free
The text was updated successfully, but these errors were encountered: