Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 of 15 tasks
terencehonles opened this issue Jun 26, 2021 · 2 comments
Closed
1 of 15 tasks

Comments

@terencehonles
Copy link

terencehonles commented Jun 26, 2021

🐞 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.

terencehonles added a commit to terencehonles/angular-cli that referenced this issue Jun 26, 2021
…g the output path

According to `rmdirSync` [1] the `recursive` option is deprecated. The
wording looks like it was changed (compared to Node LTS [2]) to not
include anything about ignoring errors on paths not existing. In the
future the call should be `rmSync(..., {..., force: true})`, but when
testing locally adding a "force" option does not restore the previous
behavior. This isn't documented to work, but since the code original
code is deprecated I was wondering if the underlying functionality was
just passing all the options `rmSync` on Node 16.

This change includes an existence check to skip deleting a non existent
directory.

closes: angular#21216

[1]: https://nodejs.org/api/fs.html#fs_fs_rmdirsync_path_options
[2]: https://nodejs.org/docs/latest-v14.x/api/fs.html#fs_fs_rmdirsync_path_options
@alan-agius4
Copy link
Collaborator

Duplicate of #21202

@alan-agius4 alan-agius4 marked this as a duplicate of #21202 Jun 27, 2021
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jul 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants