Skip to content

Fix NotADirectoryError in tools/pkg/build.py salt_onedir#69462

Open
dwoz wants to merge 2 commits into
saltstack:masterfrom
dwoz:fix/tools-pkg-build-notadir-master
Open

Fix NotADirectoryError in tools/pkg/build.py salt_onedir#69462
dwoz wants to merge 2 commits into
saltstack:masterfrom
dwoz:fix/tools-pkg-build-notadir-master

Conversation

@dwoz

@dwoz dwoz commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Commit 9c268db added a git add -f salt/_version.txt invocation inside salt_onedir with cwd=str(salt_archive), but salt_archive is a .tar.gz file path, not a directory. Python's subprocess calls chdir() on cwd and raises NotADirectoryError: [Errno 20] Not a directory: '/.../salt-3008.0+NNN.gSHA.tar.gz'.
  • This blocks the Build Salt Onedir job on Linux and macOS for every master PR. The Windows path takes a different branch (pkg\windows\install_salt.cmd) and is unaffected.
  • The salt_onedir step runs in the salt source checkout (the CI working tree), which is a real git repository containing salt/_version.txt. Dropping the broken cwd= argument lets the subprocess inherit that directory and the git add works as the original commit intended.

Fixes #69461
Refs 9c268db

Reproducer

import subprocess
subprocess.run(['echo', 'x'], cwd='/tmp/anything.tar.gz')
# NotADirectoryError: [Errno 20] Not a directory: '/tmp/anything.tar.gz'

Test plan

  • CI Build Salt Onedir jobs (Linux + macOS) succeed on this PR.
  • Downstream pip install of the source tarball still picks up salt/_version.txt via setuptools_scm.

dwoz and others added 2 commits June 21, 2026 17:54
Commit 9c268db added a `git add -f salt/_version.txt` invocation
inside `salt_onedir` with `cwd=str(salt_archive)`, but `salt_archive`
is a path to a `.tar.gz` file, not a directory.  Python's subprocess
implementation calls `chdir()` on `cwd` and raises:

    NotADirectoryError: [Errno 20] Not a directory:
    '/.../salt-3008.0+NNN.gSHA.tar.gz'

This blocks the Build Salt Onedir job on Linux and macOS for every
master PR.  The Windows path takes a different branch
(`pkg\\windows\\install_salt.cmd`) and is unaffected.

The `salt_onedir` step runs in the salt source checkout (the CI
working tree), which is a real git repository containing
`salt/_version.txt`, so dropping the `cwd=` argument lets the
subprocess inherit that directory and the `git add` works as the
original commit intended.

Reproducer:

    import subprocess
    subprocess.run(['echo', 'x'], cwd='/tmp/anything.tar.gz')
    # NotADirectoryError: [Errno 20] Not a directory: '/tmp/anything.tar.gz'

Fixes saltstack#69461
Refs 9c268db
…rors

Forward-port from 3008.x commit 3fafbbe to master:

- salt/states/file.py: prefix the early `_error()` return in
  `file.managed` with "Unable to manage file:" so callers and tests can
  reliably distinguish the manage-file failure path from other state
  errors. Restores the assertion checked by
  tests/pytests/functional/states/file/test_managed.py::test_issue_60203,
  which is failing across every functional-zeromq-3 chunk on master.

- salt/modules/file.py: route the `source_hash` value through
  `salt.utils.url.redact_http_basic_auth()` in both the "format is
  invalid" and "Source hash file not found" error paths of
  `get_source_sum()` so HTTP basic-auth credentials are not leaked into
  state comments or logs when the source hash URI is malformed or
  unreachable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:full Run the full test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NotADirectoryError in tools/pkg/build.py salt_onedir breaks Build Salt Onedir on Linux/macOS

1 participant