Loading workspace insights... Statistics interval
7 days30 daysLatest CI Pipeline Executions
8a4a4f98 fix(core): allow {projectRoot} after the start of an output when project is at the workspace root (#35993)
## Current Behavior
When a project sits at the workspace root (`projectRoot` is `.`), any
output that uses `{projectRoot}`
after the start of the expression — e.g. the `targetDefaults` output
`{workspaceRoot}/test/{projectRoot}` — fails task graph creation with:
```
NX Output '{workspaceRoot}/test/{projectRoot}' is invalid. When
{projectRoot} is '.', it can only be
used at the beginning of the expression.
```
This commonly bites when a plugin (e.g. `@nx/vitest` via a root
`vitest.config.ts`) infers a target
for the root project and a name-based target default supplies the
outputs. Because the error throws
during task graph creation, it fails any run that includes the root
project, and the user can't fix it
from `targetDefaults` alone since the default is shared by all projects.
## Expected Behavior
`{projectRoot}` is interpolated for root projects regardless of its
position, and the resulting path
is normalized:
- `{workspaceRoot}/test/{projectRoot}` → `test`
- `{workspaceRoot}/dist/{projectRoot}/sub` → `dist/sub`
### Why removing the guard is safe
The throw was added in 40b39b2e64 (Dec 2022, alongside the introduction
of root/standalone projects)
for two reasons, and neither holds anymore:
1. **Path normalization.** At the time, `interpolate()` was a naive
string replace, so
`coverage/{projectRoot}` for a root project would have produced the
unnormalized path `coverage/.`.
#26244 rewrote the function to split segments and `join()` them, which
resolves `.` cleanly — the
beginning-position case (`{projectRoot}/dist` → `dist`) already works
this way today.
2. **Output overlap.** For a root project,
`{workspaceRoot}/coverage/{projectRoot}` collapses to
`coverage`, a parent of every other project's `coverage/<root>` output
(which is why that commit also
migrated the jest defaults to `{projectName}`). But the guard only
blocks one spelling of this: a root
project with `{projectRoot}/coverage` or a literal
`{workspaceRoot}/coverage` output produces the
identical overlap and is allowed today. Nx has no overlap detection for
outputs in general —
overlapping outputs are already permitted everywhere else, while this
hard error leaves users of
shared target defaults with no escape hatch.
Verified against a minimal reproduction (root project with a `test`
target + `"outputs":
["{workspaceRoot}/test/{projectRoot}"]` in `targetDefaults`): fails on
nx 22.7.5, succeeds with this
change; non-root projects are unaffected.
## Related Issue(s)
Fixes #35839 8a4a4f98 fix(core): allow {projectRoot} after the start of an output when project is at the workspace root (#35993)
## Current Behavior
When a project sits at the workspace root (`projectRoot` is `.`), any
output that uses `{projectRoot}`
after the start of the expression — e.g. the `targetDefaults` output
`{workspaceRoot}/test/{projectRoot}` — fails task graph creation with:
```
NX Output '{workspaceRoot}/test/{projectRoot}' is invalid. When
{projectRoot} is '.', it can only be
used at the beginning of the expression.
```
This commonly bites when a plugin (e.g. `@nx/vitest` via a root
`vitest.config.ts`) infers a target
for the root project and a name-based target default supplies the
outputs. Because the error throws
during task graph creation, it fails any run that includes the root
project, and the user can't fix it
from `targetDefaults` alone since the default is shared by all projects.
## Expected Behavior
`{projectRoot}` is interpolated for root projects regardless of its
position, and the resulting path
is normalized:
- `{workspaceRoot}/test/{projectRoot}` → `test`
- `{workspaceRoot}/dist/{projectRoot}/sub` → `dist/sub`
### Why removing the guard is safe
The throw was added in 40b39b2e64 (Dec 2022, alongside the introduction
of root/standalone projects)
for two reasons, and neither holds anymore:
1. **Path normalization.** At the time, `interpolate()` was a naive
string replace, so
`coverage/{projectRoot}` for a root project would have produced the
unnormalized path `coverage/.`.
#26244 rewrote the function to split segments and `join()` them, which
resolves `.` cleanly — the
beginning-position case (`{projectRoot}/dist` → `dist`) already works
this way today.
2. **Output overlap.** For a root project,
`{workspaceRoot}/coverage/{projectRoot}` collapses to
`coverage`, a parent of every other project's `coverage/<root>` output
(which is why that commit also
migrated the jest defaults to `{projectName}`). But the guard only
blocks one spelling of this: a root
project with `{projectRoot}/coverage` or a literal
`{workspaceRoot}/coverage` output produces the
identical overlap and is allowed today. Nx has no overlap detection for
outputs in general —
overlapping outputs are already permitted everywhere else, while this
hard error leaves users of
shared target defaults with no escape hatch.
Verified against a minimal reproduction (root project with a `test`
target + `"outputs":
["{workspaceRoot}/test/{projectRoot}"]` in `targetDefaults`): fails on
nx 22.7.5, succeeds with this
change; non-root projects are unaffected.
## Related Issue(s)
Fixes #35839 8a4a4f98 fix(core): allow {projectRoot} after the start of an output when project is at the workspace root (#35993)
## Current Behavior
When a project sits at the workspace root (`projectRoot` is `.`), any
output that uses `{projectRoot}`
after the start of the expression — e.g. the `targetDefaults` output
`{workspaceRoot}/test/{projectRoot}` — fails task graph creation with:
```
NX Output '{workspaceRoot}/test/{projectRoot}' is invalid. When
{projectRoot} is '.', it can only be
used at the beginning of the expression.
```
This commonly bites when a plugin (e.g. `@nx/vitest` via a root
`vitest.config.ts`) infers a target
for the root project and a name-based target default supplies the
outputs. Because the error throws
during task graph creation, it fails any run that includes the root
project, and the user can't fix it
from `targetDefaults` alone since the default is shared by all projects.
## Expected Behavior
`{projectRoot}` is interpolated for root projects regardless of its
position, and the resulting path
is normalized:
- `{workspaceRoot}/test/{projectRoot}` → `test`
- `{workspaceRoot}/dist/{projectRoot}/sub` → `dist/sub`
### Why removing the guard is safe
The throw was added in 40b39b2e64 (Dec 2022, alongside the introduction
of root/standalone projects)
for two reasons, and neither holds anymore:
1. **Path normalization.** At the time, `interpolate()` was a naive
string replace, so
`coverage/{projectRoot}` for a root project would have produced the
unnormalized path `coverage/.`.
#26244 rewrote the function to split segments and `join()` them, which
resolves `.` cleanly — the
beginning-position case (`{projectRoot}/dist` → `dist`) already works
this way today.
2. **Output overlap.** For a root project,
`{workspaceRoot}/coverage/{projectRoot}` collapses to
`coverage`, a parent of every other project's `coverage/<root>` output
(which is why that commit also
migrated the jest defaults to `{projectName}`). But the guard only
blocks one spelling of this: a root
project with `{projectRoot}/coverage` or a literal
`{workspaceRoot}/coverage` output produces the
identical overlap and is allowed today. Nx has no overlap detection for
outputs in general —
overlapping outputs are already permitted everywhere else, while this
hard error leaves users of
shared target defaults with no escape hatch.
Verified against a minimal reproduction (root project with a `test`
target + `"outputs":
["{workspaceRoot}/test/{projectRoot}"]` in `targetDefaults`): fails on
nx 22.7.5, succeeds with this
change; non-root projects are unaffected.
## Related Issue(s)
Fixes #35839 93cf1d1b fix(core): handle --help for commands that bypass workspace handling (#35989)
## Current Behavior
`--help` is silently ignored by the commands that skip `initLocal` in
`bin/nx.ts` (`new`, `init`, `configure-ai-agents`, `mcp`, `completion`,
and `graph` outside a workspace) — the command executes instead of
showing help. For example, `nx configure-ai-agents --help` fetches the
latest nx and opens the interactive agent picker.
This is because yargs' built-in help is globally disabled
(`.help(false)`, added in #32662 so `--help` can be forwarded to
executors), and the manual `--help` interception only exists on the
`initLocal` path. `init` and `mcp` had grown per-command workarounds in
their builders to compensate; the other commands had nothing. `--help`
was also missing from every command's options list in help output.
## Expected Behavior
- `nx configure-ai-agents --help`, `nx completion --help`, `nx new
--help`, etc. print the command's help instead of executing it.
- The entry point in `bin/nx.ts` intercepts `--help` (when it appears
before any `--` separator) the same way `initLocal` does, using
`getHelp()` so commands with async builders (`init`, `mcp`) render
correctly.
- `init`'s now-redundant builder workaround is removed; its help output
improves (now includes the usage line and description). `mcp`'s builder
help is intentionally kept — it delegates to the nx-mcp package's own
help and still works.
- `--help` is declared as a global option (mirroring how `--version` is
declared but handled in `nx.ts`), so it shows up in every command's
options list.
- Executor help forwarding is unchanged: `nx run proj:target --help` and
infix `nx test proj --help` still show the executor's schema help
(verified against a scratch workspace), and tasks still run.
## Related Issue(s)
N/A — hit directly when running `nx configure-ai-agents --help`.
<!-- polygraph-session-start -->
---
[View session information
↗](https://app.trypolygraph.com/orgs/6a061dcb561c062131116eca/sessions/Fix---help-ignored-for-CLI-commands-bypassing-initLocal-2a9721f5)
<!-- polygraph-session-end -->
---------
Co-authored-by: nx-cloud[bot] <71083854+nx-cloud[bot]@users.noreply.github.com> 93cf1d1b fix(core): handle --help for commands that bypass workspace handling (#35989)
## Current Behavior
`--help` is silently ignored by the commands that skip `initLocal` in
`bin/nx.ts` (`new`, `init`, `configure-ai-agents`, `mcp`, `completion`,
and `graph` outside a workspace) — the command executes instead of
showing help. For example, `nx configure-ai-agents --help` fetches the
latest nx and opens the interactive agent picker.
This is because yargs' built-in help is globally disabled
(`.help(false)`, added in #32662 so `--help` can be forwarded to
executors), and the manual `--help` interception only exists on the
`initLocal` path. `init` and `mcp` had grown per-command workarounds in
their builders to compensate; the other commands had nothing. `--help`
was also missing from every command's options list in help output.
## Expected Behavior
- `nx configure-ai-agents --help`, `nx completion --help`, `nx new
--help`, etc. print the command's help instead of executing it.
- The entry point in `bin/nx.ts` intercepts `--help` (when it appears
before any `--` separator) the same way `initLocal` does, using
`getHelp()` so commands with async builders (`init`, `mcp`) render
correctly.
- `init`'s now-redundant builder workaround is removed; its help output
improves (now includes the usage line and description). `mcp`'s builder
help is intentionally kept — it delegates to the nx-mcp package's own
help and still works.
- `--help` is declared as a global option (mirroring how `--version` is
declared but handled in `nx.ts`), so it shows up in every command's
options list.
- Executor help forwarding is unchanged: `nx run proj:target --help` and
infix `nx test proj --help` still show the executor's schema help
(verified against a scratch workspace), and tasks still run.
## Related Issue(s)
N/A — hit directly when running `nx configure-ai-agents --help`.
<!-- polygraph-session-start -->
---
[View session information
↗](https://app.trypolygraph.com/orgs/6a061dcb561c062131116eca/sessions/Fix---help-ignored-for-CLI-commands-bypassing-initLocal-2a9721f5)
<!-- polygraph-session-end -->
---------
Co-authored-by: nx-cloud[bot] <71083854+nx-cloud[bot]@users.noreply.github.com> 93cf1d1b fix(core): handle --help for commands that bypass workspace handling (#35989)
## Current Behavior
`--help` is silently ignored by the commands that skip `initLocal` in
`bin/nx.ts` (`new`, `init`, `configure-ai-agents`, `mcp`, `completion`,
and `graph` outside a workspace) — the command executes instead of
showing help. For example, `nx configure-ai-agents --help` fetches the
latest nx and opens the interactive agent picker.
This is because yargs' built-in help is globally disabled
(`.help(false)`, added in #32662 so `--help` can be forwarded to
executors), and the manual `--help` interception only exists on the
`initLocal` path. `init` and `mcp` had grown per-command workarounds in
their builders to compensate; the other commands had nothing. `--help`
was also missing from every command's options list in help output.
## Expected Behavior
- `nx configure-ai-agents --help`, `nx completion --help`, `nx new
--help`, etc. print the command's help instead of executing it.
- The entry point in `bin/nx.ts` intercepts `--help` (when it appears
before any `--` separator) the same way `initLocal` does, using
`getHelp()` so commands with async builders (`init`, `mcp`) render
correctly.
- `init`'s now-redundant builder workaround is removed; its help output
improves (now includes the usage line and description). `mcp`'s builder
help is intentionally kept — it delegates to the nx-mcp package's own
help and still works.
- `--help` is declared as a global option (mirroring how `--version` is
declared but handled in `nx.ts`), so it shows up in every command's
options list.
- Executor help forwarding is unchanged: `nx run proj:target --help` and
infix `nx test proj --help` still show the executor's schema help
(verified against a scratch workspace), and tasks still run.
## Related Issue(s)
N/A — hit directly when running `nx configure-ai-agents --help`.
<!-- polygraph-session-start -->
---
[View session information
↗](https://app.trypolygraph.com/orgs/6a061dcb561c062131116eca/sessions/Fix---help-ignored-for-CLI-commands-bypassing-initLocal-2a9721f5)
<!-- polygraph-session-end -->
---------
Co-authored-by: nx-cloud[bot] <71083854+nx-cloud[bot]@users.noreply.github.com>