Skip to content

fix(core): include a file's executable bit in its hash - #37706

Open
itisrmk wants to merge 1 commit into
nrwl:masterfrom
itisrmk:fix/hash-exec-bit
Open

itisrmk wants to merge 1 commit into
nrwl:masterfrom
itisrmk:fix/hash-exec-bit

Conversation

@itisrmk

@itisrmk itisrmk commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Current Behavior

A task hash ignores file modes. After chmod +x or chmod -x on an input, Nx hits the local cache and restores outputs built for the old mode. chmod changes neither the file's bytes nor its mtime, and the files archive and the ignored-file index both reuse a stored hash when the mtime (and, for the index, the size) still match. The run exits 0. The same thing happens with the change uncommitted and after it is committed. git records the mode.

Expected Behavior

On Unix, the executable bit is part of an input's identity, as it is in git (mode & 0o111 != 0). Changing only that bit moves the file hash, misses both stamps, and moves the task hash. A non-executable file keeps its content-only hash. Off Unix, file hashes and stamps are unchanged.

Related Issue(s)

Fixes #37459

@itisrmk
itisrmk requested a review from a team as a code owner October 31, 2026 20:15
@netlify

netlify Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

👷 Deploy request for nx-docs pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit ac3f055

@itisrmk
itisrmk requested a review from leosvelperez October 31, 2026 20:15
@netlify

netlify Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

👷 Deploy request for nx-dev pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit ac3f055

@leosvelperez leosvelperez self-assigned this Nov 2, 2026

itisrmk commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

Hi! Could a maintainer approve the CI workflows for this PR when you have a moment? Thanks.

chmod does not change mtime or file bytes, so a mode-only change reused the cached task hash and restored outputs built for the other mode. On unix the bit is mixed into the content hash and into the ignored-index stamp; the files archive's metadata key already moves with the ctime that chmod updates, and the watcher admits file chmod events.

Co-authored-by: Rahul Kashyap <itisrmk@users.noreply.github.com>
Co-Authored-By: Rahul Kashayp <rahulmkashyap@gmail.com>
@itisrmk

itisrmk commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto current master to resolve the conflicts with the new files-archive metadata key. That key already includes the ctime, which chmod updates, so I dropped the mode bit this PR had packed into the archive stamp and kept the rest: the executable bit in the content hash, the ignored-index stamp, and the watcher admitting file chmod events. should_rehash_when_only_the_executable_bit_changes now checks the archive against the metadata key. cargo test --lib -- hasher files_hashing ignored_index watch_filterer workspace::context outputs_tracking passes (201 tests).

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Changing only a file's executable bit keeps the task hash, so the old outputs are restored

3 participants