Skip to content

Conversation

@AgentEnder
Copy link
Member

Current Behavior

There is no straight-forward way to use the cwd as part of a tasks hash

Expected Behavior

You can use {workingDirectory: 'absolute'} to factor the working directory into the hash

Related Issue(s)

Fixes #33684

@AgentEnder AgentEnder requested review from a team and FrozenPandaz as code owners December 15, 2025 22:44
@vercel
Copy link

vercel bot commented Dec 15, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
nx-dev Ready Ready Preview Dec 19, 2025 9:45pm

@netlify
Copy link

netlify bot commented Dec 15, 2025

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit 259132e
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/6945c587c5ccce00088c3701
😎 Deploy Preview https://deploy-preview-33879--nx-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@nx-cloud
Copy link
Contributor

nx-cloud bot commented Dec 15, 2025

View your CI Pipeline Execution ↗ for commit 259132e

Command Status Duration Result
nx affected --targets=lint,test,test-kt,build,e... ✅ Succeeded 51m 29s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 2m 44s View ↗
nx-cloud record -- nx-cloud conformance:check ✅ Succeeded 12s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 3s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded <1s View ↗
nx affected -t e2e-macos-local --parallel=1 --b... ✅ Succeeded 49m 52s View ↗

☁️ Nx Cloud last updated this comment at 2025-12-19 22:42:50 UTC

nx-cloud[bot]

This comment was marked as outdated.

Copy link
Contributor

@Coly010 Coly010 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should react have needed changes? What changed that this wasn’t an issue before?

nx-cloud[bot]

This comment was marked as outdated.

@AgentEnder
Copy link
Member Author

Should react have needed changes? What changed that this wasn’t an issue before?

@Coly010 i think this is the first time wece updated these typing since we moved to ts project refs and its exposing places where the typing were pulling in the wrong version of nx.

nx-cloud[bot]

This comment was marked as outdated.

nx-cloud[bot]

This comment was marked as outdated.

nx-cloud[bot]

This comment was marked as outdated.

nx-cloud[bot]

This comment was marked as outdated.

nx-cloud[bot]

This comment was marked as outdated.

nx-cloud[bot]

This comment was marked as outdated.

The `workingDirectory` input accepts two values:

- `"relative"` - Hashes the relative path from the workspace root to the current working directory. This is useful when tasks should be invalidated when run from different subdirectories within the workspace.
- `"absolute"` - Hashes the full absolute path of the current working directory. This is useful when tasks depend on the exact location on the filesystem.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should mention that this will invalidate the cache if the repo is checked out to different locations such as local vs CI... or even developer 1 vs developer 2

}
HashInstruction::Cwd(mode) => {
let workspace_root = std::path::Path::new(&self.workspace_root);
let cwd = std::env::current_dir().unwrap_or_default();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can't use the process cwd... because this might be on the daemon...when it should be the one from the main nx command.

Copy link
Contributor

@nx-cloud nx-cloud bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ The fix from Nx Cloud was applied

These changes fix the formatting failure in the astro-docs:format task by running Prettier on the inputs.mdoc file. The formatting issue was caused by the documentation changes for the new workingDirectory input feature, which added a JSON example that needed a trailing comma to comply with Prettier's style rules.

We had verified this fix by re-running astro-docs:format.

Suggested Fix changes
diff --git a/astro-docs/src/content/docs/reference/inputs.mdoc b/astro-docs/src/content/docs/reference/inputs.mdoc
index 49a48aaa66..bf8413216f 100644
--- a/astro-docs/src/content/docs/reference/inputs.mdoc
+++ b/astro-docs/src/content/docs/reference/inputs.mdoc
@@ -95,8 +95,8 @@ Some tasks may behave differently depending on which directory they are run from
 ​`​`​`jsonc
 {
   "inputs": [
-    { "workingDirectory": "relative" } // Hash the path relative to workspace root
-  ]
+    { "workingDirectory": "relative" }, // Hash the path relative to workspace root
+  ],
 }
 ​`​`​`
 

Revert fix via Nx Cloud  

View interactive diff ↗
This fix was applied by Craigory Coppola

🎓 Learn more about Self-Healing CI on nx.dev

fix(dotnet): include cwd in target hash

Fixes #33684

fix(repo): ensure appropriate typings are present

fix(repo): ensure appropriate typings are present

Co-authored-by: AgentEnder <AgentEnder@users.noreply.github.com>

fix(core): add workingDirectory to input validation check

Co-authored-by: AgentEnder <AgentEnder@users.noreply.github.com>

fix(core): add workingDirectory to input validation check

Co-authored-by: AgentEnder <AgentEnder@users.noreply.github.com> [Self-Healing CI Rerun]

fix(core): pass client cwd to daemon for task hashing

The daemon process runs from a fixed location (workspace root), so using
std::env::current_dir() in the native task hasher would always return
the daemon's cwd rather than where the user invoked the command.

This fix passes the client's actual cwd through the daemon IPC to ensure
the workingDirectory input hashes correctly based on where commands are
executed from.
let hash_time = std::time::Instant::now();

let hashes: NapiDashMap<String, HashDetails> = NapiDashMap::new();
let cwd_path = std::path::Path::new(&cwd);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this have to be fully qualiffied?

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.

@nx/dotnet: Remote cache restoration fails across CI agents due to absolute paths in .NET obj/ artifacts

4 participants