saltstack / salt

Software to automate the management and configuration of any infrastructure or application at scale. Get access to the Salt software package repository here:
https://repo.saltproject.io/
Apache License 2.0
14.12k stars 5.47k forks source link

[BUG] Salt 3007.0 Microsoft Visual C++ 2015 #66258

Open cdtylejenk opened 6 months ago

cdtylejenk commented 6 months ago

Description When attempting to run salt-call on 3007.0, the following error is returned:

Traceback (most recent call last):
  File "C:\Program Files\Salt Project\Salt\Lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\Salt Project\Salt\Lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Program Files\Salt Project\Salt\salt-call.exe\__main__.py", line 7, in <module>
  File "C:\Program Files\Salt Project\Salt\Lib\site-packages\salt\scripts.py", line 437, in salt_call
    import salt.cli.call
  File "C:\Program Files\Salt Project\Salt\Lib\site-packages\salt\cli\call.py", line 3, in <module>
    import salt.cli.caller
  File "C:\Program Files\Salt Project\Salt\Lib\site-packages\salt\cli\caller.py", line 12, in <module>
    import salt.channel.client
  File "C:\Program Files\Salt Project\Salt\Lib\site-packages\salt\channel\client.py", line 14, in <module>
    import salt.crypt
  File "C:\Program Files\Salt Project\Salt\Lib\site-packages\salt\crypt.py", line 32, in <module>
    import salt.utils.event
  File "C:\Program Files\Salt Project\Salt\Lib\site-packages\salt\utils\event.py", line 68, in <module>
    import salt.config
  File "C:\Program Files\Salt Project\Salt\Lib\site-packages\salt\config\__init__.py", line 18, in <module>
    import salt.syspaths
  File "C:\Program Files\Salt Project\Salt\Lib\site-packages\salt\syspaths.py", line 129, in <module>
    ROOT_DIR = _get_windows_root_dir()
  File "C:\Program Files\Salt Project\Salt\Lib\site-packages\salt\syspaths.py", line 100, in _get_windows_root_dir
    root_dir = salt.utils.win_reg.read_value(
  File "C:\Program Files\Salt Project\Salt\Lib\site-packages\salt\utils\win_reg.py", line 536, in read_value
    registry = Registry()
  File "C:\Program Files\Salt Project\Salt\Lib\site-packages\salt\utils\win_reg.py", line 102, in __init__
    "HKEY_CURRENT_CONFIG": win32con.HKEY_CURRENT_CONFIG,
NameError: name 'win32con' is not defined

win_reg.py is trying to import a few different win32 libraries:

try:
    import win32api
    import win32con
    import win32gui

    HAS_WINDOWS_MODULES = True
except ImportError:
    HAS_WINDOWS_MODULES = False

If I import these individually, I see the culprits are actually win32api & win32gui:

>>> import win32con
>>> import win32api
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: DLL load failed while importing win32api: The specified module could not be found.
>>> import win32gui
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: DLL load failed while importing win32gui: The specified module could not be found.

I see that pythoncom310.dll & pywintypes310.dll refer to the following dependencies:

pythoncom310.dll    
   OLEAUT32.dll
    ole32.dll
    USER32.dll
    python310.dll
    pywintypes310.dll
    KERNEL32.dll
    VCRUNTIME140_1.dll
    VCRUNTIME140.dll
    api-ms-win-crt-stdio-l1-1-0.dll
    api-ms-win-crt-string-l1-1-0.dll
    api-ms-win-crt-heap-l1-1-0.dll
    api-ms-win-crt-utility-l1-1-0.dll
    api-ms-win-crt-runtime-l1-1-0.dll

pywintypes310.dll   
    ADVAPI32.dll
    USER32.dll
    ole32.dll
    OLEAUT32.dll
    python310.dll
    KERNEL32.dll
    VCRUNTIME140_1.dll
    VCRUNTIME140.dll
    api-ms-win-crt-heap-l1-1-0.dll
    api-ms-win-crt-stdio-l1-1-0.dll
    api-ms-win-crt-time-l1-1-0.dll
    api-ms-win-crt-string-l1-1-0.dll
    api-ms-win-crt-runtime-l1-1-0.dll
    api-ms-win-crt-math-l1-1-0.dll

Looks like api-ms-win-crt-* refer to the 2015 redistributable. If I install the latest redistributable here, then salt-call works fine: https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170

During the setup process, I see that the salt executable found here: https://docs.saltproject.io/salt/install-guide/en/latest/topics/install-by-operating-system/windows.html#install-windows

Is still trying to install 2013: 2013

Setup

Installing Salt via the exe here: https://docs.saltproject.io/salt/install-guide/en/latest/topics/install-by-operating-system/windows.html#install-windows

Steps to Reproduce the behavior

Expected behavior Expecting Salt 3007.0 to install Microsoft Visual C++ 2015 instead of 2013 during the setup process.

Screenshots winreg

Versions Report salt-call --versions-report also returns the win_reg.py error message.

welcome[bot] commented 6 months ago

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. Please be sure to review our Code of Conduct. Also, check out some of our community resources including:

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. If you have additional questions, email us at saltproject@vmware.com. We’re glad you’ve joined our community and look forward to doing awesome things with you!

hbonath commented 6 months ago

Just jumping in here to confirm this affects Windows Server 2019 (And likely all other versions of windows)

amalaguti commented 5 months ago

Confirming the same

[ERROR   ] An un-handled exception was caught by Salt's global exception handler:
NameError: name 'win32con' is not defined
Traceback (most recent call last):
  File "C:\Program Files\Salt Project\Salt\Lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\Salt Project\Salt\Lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Program Files\Salt Project\Salt\salt-minion.exe\__main__.py", line 7, in <module>
    sys.exit(salt_minion())
  File "C:\Program Files\Salt Project\Salt\Lib\site-packages\salt\scripts.py", line 174, in salt_minion
    import salt.cli.daemons
  File "C:\Program Files\Salt Project\Salt\Lib\site-packages\salt\cli\daemons.py", line 12, in <module>
    from salt.utils import migrations
  File "C:\Program Files\Salt Project\Salt\Lib\site-packages\salt\utils\migrations.py", line 8, in <module>
    import salt.syspaths as syspaths
  File "C:\Program Files\Salt Project\Salt\Lib\site-packages\salt\syspaths.py", line 129, in <module>
    ROOT_DIR = _get_windows_root_dir()
  File "C:\Program Files\Salt Project\Salt\Lib\site-packages\salt\syspaths.py", line 100, in _get_windows_root_dir
    root_dir = salt.utils.win_reg.read_value(
  File "C:\Program Files\Salt Project\Salt\Lib\site-packages\salt\utils\win_reg.py", line 536, in read_value
    registry = Registry()
  File "C:\Program Files\Salt Project\Salt\Lib\site-packages\salt\utils\win_reg.py", line 102, in __init__
    "HKEY_CURRENT_CONFIG": win32con.HKEY_CURRENT_CONFIG,
NameError: name 'win32con' is not defined