Skip to content

fix(misc): allow create-nx-workspace . --no-interactive in empty directory#35281

Open
cogwirrel wants to merge 2 commits intonrwl:masterfrom
cogwirrel:cogwirrel/fix-daemon-graph-cache
Open

fix(misc): allow create-nx-workspace . --no-interactive in empty directory#35281
cogwirrel wants to merge 2 commits intonrwl:masterfrom
cogwirrel:cogwirrel/fix-daemon-graph-cache

Conversation

@cogwirrel
Copy link
Copy Markdown
Contributor

@cogwirrel cogwirrel commented Apr 14, 2026

Current Behavior

Running create-nx-workspace . --no-interactive inside an empty directory fails with:

The directory '<dirname>' already exists. Choose a different name or remove the existing directory.

This happens because resolveSpecialFolderName(".") resolves to { name: basename(cwd), workingDir: dirname(cwd) }, and then determineFolder() checks existsSync(join(workingDir, name)) — which is the current directory itself, so it always exists. In interactive mode, this triggers a re-prompt that happens to work. In non-interactive mode, it throws the error.

Additionally, running create-nx-workspace --no-interactive without any name falls through to promptForFolder which silently uses 'org' as the default name rather than the current directory name.

Expected Behavior

  • create-nx-workspace . --no-interactive should work in an empty directory, creating the workspace in-place (the same way it works in interactive mode).
  • create-nx-workspace --no-interactive without a name should default to the current directory name.

Related Issue(s)

Fixes #35278

@cogwirrel cogwirrel requested a review from a team as a code owner April 14, 2026 08:00
@cogwirrel cogwirrel requested a review from lourw April 14, 2026 08:00
@netlify
Copy link
Copy Markdown

netlify bot commented Apr 14, 2026

👷 Deploy request for nx-docs pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 00fe241

@netlify
Copy link
Copy Markdown

netlify bot commented Apr 14, 2026

👷 Deploy request for nx-dev pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 00fe241

@cogwirrel cogwirrel force-pushed the cogwirrel/fix-daemon-graph-cache branch from 67f29d2 to 12aa858 Compare April 14, 2026 08:18
…ctory

When using "." or "./" as the workspace name, resolveSpecialFolderName
already validates the directory is empty. Skip the subsequent existsSync
check that always returns true (since the target IS the current
directory), which previously caused a spurious "directory already exists"
error in non-interactive mode.

Also defaults the workspace name to basename(cwd) when --no-interactive
is passed without an explicit name.

Fixes nrwl#35278

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@cogwirrel cogwirrel force-pushed the cogwirrel/fix-daemon-graph-cache branch from 12aa858 to 9f4a941 Compare April 14, 2026 08:21
@nx-cloud
Copy link
Copy Markdown
Contributor

nx-cloud bot commented Apr 15, 2026

View your CI Pipeline Execution ↗ for commit 9f4a941

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 14m 3s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 3s View ↗
nx-cloud record -- pnpm nx conformance:check ✅ Succeeded 7s View ↗
nx build workspace-plugin ✅ Succeeded <1s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 2s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2026-04-15 20:36:00 UTC

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.

create-nx-workspace: `." fails with --no-interactive in an empty directory

2 participants