Skip to content

default option --delete-output-path breaks building on a CI (or clean environment) #21216

Closed
@terencehonles

Description

@terencehonles

🐞 Bug report

Command (mark with an x)

  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • extract-i18n
  • run
  • config
  • help
  • version
  • doc

Is this a regression?

Yes, this broke in 12.1.0 (so 12.0.0 worked) and is "related" to #21049 (but it looks like it's a bug(?)/change in Node and might also break rimraf).

Description

When trying to build on a clean environment (such as a CI) the builder will try to delete the output path which does not exist. On Node 16 this is an error and {recursive: true} does not silence this error.

A clear and concise description of the problem...

🔬 Minimal Reproduction

docker run --rm node:latest -e 'fs.rmdirSync("/this/does/not/exist", {recursive: true, maxRetries: 3})'
node:internal/fs/utils:343
    throw err;
    ^

Error: ENOENT: no such file or directory, stat '/this/does/not/exist'
    at Object.statSync (node:fs:1527:3)
    at __node_internal_ (node:internal/fs/utils:767:8)
    at Object.rmdirSync (node:fs:1147:15)
    at [eval]:1:4
    at Script.runInThisContext (node:vm:131:12)
    at Object.runInThisContext (node:vm:308:38)
    at node:internal/process/execution:81:19
    at [eval]-wrapper:6:22
    at evalScript (node:internal/process/execution:80:60)
    at node:internal/main/eval_string:27:3 {
  errno: -2,
  syscall: 'stat',
  code: 'ENOENT',
  path: '/this/does/not/exist'
}

🔥 Exception or Error

output is from docker build with buildkit so that's the prefix


#27 0.664 + npm run build
#27 1.556                                                                                                                   
#27 1.556 > [email protected] build                                                                                           
#27 1.556 > ng build
#27 1.556                                                                                                                   
#27 8.243 An unhandled exception occurred: ENOENT: no such file or directory, stat '/code/app'         
#27 8.243 See "/tmp/ng-1XRgEQ/angular-errors.log" for further details.                                                      
#27 8.278 + EXIT_CODE=127                                                                                                   
#27 8.278 + tail -n +1 /tmp/ng-1XRgEQ/angular-errors.log                                                                    
#27 8.278 [error] Error: ENOENT: no such file or directory, stat '/code/app'
#27 8.278     at Object.statSync (node:fs:1527:3)
#27 8.278     at __node_internal_ (node:internal/fs/utils:767:8)
#27 8.278     at Object.rmdirSync (node:fs:1147:15)
#27 8.278     at Object.deleteOutputDir (/code/node_modules/@angular-devkit/build-angular/src/utils/delete-output-dir.js:21:10)
#27 8.278     at initialize (/code/node_modules/@angular-devkit/build-angular/src/browser/index.js:86:17)
#27 8.278     at async SwitchMapSubscriber.project (/code/node_modules/@angular-devkit/build-angular/src/browser/index.js:114:17)

🌍 Your Environment


> [email protected] ng /code
> ng "version"


     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 12.1.0
Node: 14.17.1
Package Manager: npm 6.14.13
OS: linux x64

Angular: 12.1.0
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, google-maps, language-service, localize, material
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1201.0
@angular-devkit/build-angular   12.1.0
@angular-devkit/core            12.1.0
@angular-devkit/schematics      12.1.0
@schematics/angular             12.1.0
rxjs                            6.6.7
typescript                      4.2.4

Anything else relevant?

Running with --no-delete-output-path will fix the error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions