nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.29k stars 2.32k forks source link

Error: EEXIST: file already exists, mkdir on build default project #8128

Closed wizardnet972 closed 2 years ago

wizardnet972 commented 2 years ago

Current Behavior

Nx runs unnecessary build to defaultProject (nx.json) when affected:libs returns "workspace". If I have defaultProject I got an error:

Warning: bundle initial exceeded maximum budget. Budget 500.00 kB was not met by 55.84 kB with a total of 555.84 kB.

Unexpected error:
[Error: EEXIST: file already exists, mkdir '/Users/wizardnet972/code/nx-repo/node_modules/.cache/nx/d0432d082f39baf22e4b7a034c702ff9969651c2a5a56dc58172c62528eb8e0b/outputs/dist/out-tsc'] {
  errno: -17,
  code: 'EEXIST',
  syscall: 'mkdir',
  path: '/Users/wizardnet972/code/nx-repo/node_modules/.cache/nx/d0432d082f39baf22e4b7a034c702ff9969651c2a5a56dc58172c62528eb8e0b/outputs/dist/out-tsc'
}
error Command failed with exit code 1.

I run build on app-a and app-b (run-many) but the default is app-c.

Expected Behavior

if I don't have defaultProject then no build should run.

Steps to Reproduce

This issue may not be prioritized if details are not provided to help us reproduce the issue.

Failure Logs

Environment


  Node : 16.13.0
  OS   : darwin arm64
  yarn : 1.22.11

  nx : 13.3.0
  @nrwl/angular : 13.3.1
  @nrwl/cli : 13.3.0
  @nrwl/cypress : 13.3.0
  @nrwl/devkit : 13.3.0
  @nrwl/eslint-plugin-nx : 13.3.0
  @nrwl/express : undefined
  @nrwl/jest : 13.3.0
  @nrwl/linter : 13.3.0
  @nrwl/nest : undefined
  @nrwl/next : undefined
  @nrwl/node : 13.3.1
  @nrwl/nx-cloud : undefined
  @nrwl/react : undefined
  @nrwl/react-native : undefined
  @nrwl/schematics : undefined
  @nrwl/tao : 13.3.0
  @nrwl/web : undefined
  @nrwl/workspace : 13.3.0
  @nrwl/storybook : 13.3.1
  @nrwl/gatsby : undefined
  typescript : 4.4.4
  rxjs : 7.4.0
  ---------------------------------------
  Community plugins:
     @angular/animations: 13.1.0
     @angular/common: 13.1.0
     @angular/compiler: 13.1.0
     @angular/core: 13.1.0
     @angular/forms: 13.1.0
     @angular/platform-browser: 13.1.0
     @angular/platform-browser-dynamic: 13.1.0
     @angular/router: 13.1.0
     @ngrx/component-store: 13.0.2
     @ngrx/effects: 13.0.2
     @ngrx/entity: 13.0.2
     @ngrx/router-store: 13.0.2
     @ngrx/store: 13.0.2
     @angular-architects/ddd: 1.5.1
     @angular-devkit/build-angular: 13.0.4
     @angular/cdk: 13.1.0
     @angular/cli: 13.0.4
     @angular/compiler-cli: 13.1.0
     @angular/language-service: 13.1.0
     @angular/material: 13.1.0
     @jscutlery/semver: 2.15.0
     @ngneat/input-mask: 5.0.1
     @ngneat/scam: 3.0.4
     @ngrx/data: 13.0.2
     @ngrx/schematics: 13.0.2
     @ngrx/store-devtools: 13.0.2
     @rx-angular/template: 1.0.0-beta.29
     @storybook/angular: 6.4.9
     nx-stylelint: 13.1.0
wizardnet972 commented 2 years ago

maybe wherever you create a folder in dist, check before if they exist?

FrozenPandaz commented 2 years ago

Could you please provide a repo we can pull down to reproduce the issue?

github-actions[bot] commented 2 years ago

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! 🙏

wizardnet972 commented 2 years ago

@FrozenPandaz Hey :) I'm still trying to reproduce this issue. I think it's happened because of resource collision.

I debug the nx code though run-many.js and I found out that something is failed in finally section: https://github.com/nrwl/nx/blob/4b21ab9502f8fcc4c20db3478adcb7aa5f7a934a/packages/workspace/src/tasks-runner/default-tasks-runner.ts#L60

so the error caught in the catch section: https://github.com/nrwl/nx/blob/4b21ab9502f8fcc4c20db3478adcb7aa5f7a934a/packages/workspace/src/tasks-runner/default-tasks-runner.ts#L56

Not yet sure why.

But as far I can see I add project.json to the root project and add the entry in workspace.json.

When I run yarn nx run-many --target build --all, nx detect also "workspace" project. which triggers to build of the default project.

So I think because nx run the commands in parallel the resources of the cache/directory is occupied (in use/exist).

Think about this, I build every project including the default project. also nx build the workspace project which is the default project in parallel. same cache same files and directory.

Maybe the affected and the graph workspace should not build the default project. also what if I don't have a default project?

I had this problem for months. I will appreciate your help in this matter :)

thoussem commented 1 year ago

I have the same issue any updates please ?

github-actions[bot] commented 1 year ago

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.