Skip to content

[Bug]: Saltstack onedir powershell -File param #69959

Closed

Description

@vegcom

What happened?

Saltstack onedir powershell -File param bug

On Windows, Saltstack onedir always invokes Windows PowerShell 5.1, even when pwsh is installed.
PowerShell 5.1 rejects the -File parameter in this invocation, producing the misleading error:

"The argument '' to the -File parameter does not exist."

This is not a missing temp file — the file exists. The failure occurs because the -File
parameter is not supported by the version of PowerShell that onedir is invoking.

May be temp file handling.


You can view my salt environment at: https://github.com/vegcom/cozy-salt

Output

Windows version

➜  Get-ComputerInfo | Select-Object OsName, OsVersion

OsName                   OsVersion
------                   ---------
Microsoft Windows 11 Pro 10.0.26200
➜  Get-ComputerInfo | Select-Object WindowsProductName, WindowsVersion, OsHardwareAbstractionLayer

WindowsProductName WindowsVersion OsHardwareAbstractionLayer
------------------ -------------- --------------------------
Windows 10 Pro     2009           10.0.26100.1

Pwsh Version

sudo salt-call cmd.powershell '$PSVersionTable.PSVersion'
local:
    ----------
    Build:
        26100
    Major:
        5
    MajorRevision:
        0
    Minor:
        1
    MinorRevision:
        8972
    Revision:
        8972

Saltstack

This is a snip not the entire state. this was from cozy-salt salt-call state.sls windows.install on a windows 11 machine.

[INFO    ] Fetching file from saltenv 'base', ** done ** 'windows/files/opt-cozy-bin/winget-batch.ps1'
[DEBUG   ] ['C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.EXE', '-NonInteractive', '-NoProfile', '-ExecutionPolicy', 'Bypass', '-File', 'C:\\Users\\<user>\\AppData\\Local\\Temp\\__salt.tmp.08yacrs6.ps1', '-WingetPath', 'C:\\Users\\<user>\\AppData\\Local\\Microsoft\\WindowsApps\\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\\winget.exe', '-Packages', 'evsar3.sshfs-win-manager', '-Scope', 'user', '-SkipDeps', 'false', '-Prerelease', 'false', '-Force', 'false', '-Upgrade', 'false']
[INFO    ] No changes made for winget_batch_userland_<user>_networking
[INFO    ] Completed state [winget_batch_userland_<user>_networking] at time 11:25:07.426979 (duration_in_ms=82.899)
[INFO    ] Running state [winget_batch_userland_<user>_utilities] at time 11:25:07.427881
[INFO    ] Executing state cmd.script for [winget_batch_userland_<user>_utilities]
[DEBUG   ] In saltenv 'base', looking at rel_path 'windows/files/opt-cozy-bin/winget-batch.ps1' to resolve 'salt://windows/files/opt-cozy-bin/winget-batch.ps1'
[DEBUG   ] In saltenv 'base', ** considering ** path 'C:\ProgramData\Salt Project\Salt\var\cache\salt\minion\files\base\windows\files\opt-cozy-bin\winget-batch.ps1' to resolve 'salt://windows/files/opt-cozy-bin/winget-batch.ps1'
[DEBUG   ] Fetching file from saltenv 'base', ** attempting ** 'salt://windows/files/opt-cozy-bin/winget-batch.ps1'
[DEBUG   ] No dest file found
The argument 'C:\Users\<user>\AppData\Local\Temp\__salt.tmp.gjdcqec_.ps1' to the -File parameter does not exist. Provide the path to an existing '.ps1' file as an argument to the -File parameter.
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
[INFO    ] Fetching file from saltenv 'base', ** done ** 'windows/files/opt-cozy-bin/winget-batch.ps1'
[DEBUG   ] ['C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.EXE', '-NonInteractive', '-NoProfile', '-ExecutionPolicy', 'Bypass', '-File', 'C:\\Users\\<user>\\AppData\\Local\\Temp\\__salt.tmp.kga44l2f.ps1', '-WingetPath', 'C:/Program Files/WindowsApps/Microsoft.DesktopAppInstaller_1.29.280.0_x64__8wekyb3d8bbwe/winget.exe', '-Packages', 'Microsoft.WindowsADK,Microsoft.NuGet', '-Scope', 'machine', '-SkipDeps', 'false', '-Prerelease', 'false', '-Force', 'false', '-Upgrade', 'false']
[INFO    ] No changes made for winget_batch_runtimes_sdks
[INFO    ] Completed state [winget_batch_runtimes_sdks] at time 12:17:50.010963 (duration_in_ms=81.663)
[INFO    ] Running state [winget_batch_runtimes_ui_libraries] at time 12:17:50.012041
[INFO    ] Executing state cmd.script for [winget_batch_runtimes_ui_libraries]
[DEBUG   ] In saltenv 'base', looking at rel_path 'windows/files/opt-cozy-bin/winget-batch.ps1' to resolve 'salt://windows/files/opt-cozy-bin/winget-batch.ps1'
[DEBUG   ] In saltenv 'base', ** considering ** path 'C:\ProgramData\Salt Project\Salt\var\cache\salt\minion\files\base\windows\files\opt-cozy-bin\winget-batch.ps1' to resolve 'salt://windows/files/opt-cozy-bin/winget-batch.ps1'
[DEBUG   ] Fetching file from saltenv 'base', ** attempting ** 'salt://windows/files/opt-cozy-bin/winget-batch.ps1'
[DEBUG   ] No dest file found
The argument 'C:\Users\<user>\AppData\Local\Temp\__salt.tmp.wgqsjue3.ps1' to the -File parameter does not exist. Provide the path to an existing '.ps1' file as an argument to the -File parameter.
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Type of salt install

other (please specify in bug details)

Major version

3008.x

What supported OS are you seeing the problem on? Can select multiple. (If bug appears on an unsupported OS, please open a GitHub Discussion instead)

windows-desktop-11

salt --versions-report output

local:
    Salt Version:
              Salt: 3008.2

    Python Version:
            Python: 3.14.6 (heads/main:780a303, Jun 11 2026, 02:09:15) [MSC v.1944 64 bit (AMD64)]

    Dependency Versions:
              cffi: 2.1.1
          cherrypy: 18.10.0
      cryptography: 50.0.0
          dateutil: 2.9.0.post0
         docker-py: Not Installed
             gitdb: 4.0.12
         gitpython: 3.1.57
            Jinja2: 3.1.6
           libgit2: Not Installed
      looseversion: 1.3.0
          M2Crypto: Not Installed
              Mako: Not Installed
           msgpack: 1.2.1
      msgpack-pure: Not Installed
      mysql-python: Not Installed
         packaging: 26.2
         pycparser: 3.00
          pycrypto: Not Installed
      pycryptodome: 3.23.0
            pygit2: Not Installed
      python-gnupg: 0.5.6
            PyYAML: 6.0.3
             PyZMQ: 27.1.0
            relenv: 0.22.14
             smmap: 5.0.2
           timelib: 0.3.0
           Tornado: 6.5.7
               ZMQ: 4.3.5

    Salt Package Information:
      Package Type: onedir

    System Versions:
              dist:
            locale: utf-8
           machine: AMD64
           release: 10
            system: Windows
           version: 10 10.0.26200 SP0 Multiprocessor Free

Activity

  1. added
    bug
    on Aug 5, 2026
  2. dafyddj commented on Aug 6, 2026

    @dafyddj
    Collaborator
  3. self-assigned this
    on Aug 6, 2026
  4. added theissue type on Aug 6, 2026
  5. added this to the Sulphur v3006.28 milestone on Aug 6, 2026
  6. twangboy commented on Aug 6, 2026

    @twangboy
    Contributor

    Happens on Linux too: #50273

  7. twangboy commented on Aug 6, 2026

    @twangboy
    Contributor

    This isn’t a PowerShell 5.1 vs pwsh -File compatibility issue. Windows PowerShell 5.1 supports -File; the error means the script path is already gone when PowerShell tries to open it.

    Root cause: cmd.script always deletes its copied tempfile after _run() returns. With bg=True, _run returns immediately (it does not wait for the child), so Salt deletes __salt.tmp.*.ps1 before PowerShell can open it. That shows up as:

    The argument to the -File parameter does not exist.
    

    This is the same race as #50273 (originally seen on POSIX as No such file or directory). PR #68156 switched PowerShell cmd.script to -File, which made the missing-file failure clearer on Windows.

    In the reporter’s formula, cozy-salt’s winget_batch_install sets bg: true on cmd.script, which hits this path.

    Workaround: set bg: false (or omit bg) on the cmd.script state. Note that stateful: true + bg: true + hide_output: true can’t usefully work together anyway, since Salt does not wait for or collect background script output.

    The fix is in #69967

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions