Skip to content

ng update assumes incorrect version present #25925

@nikita-fuchs

Description

@nikita-fuchs

Command

update

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

After a failed run of ng update, successive runs will assume the presence of the version I tried updating to.

Repro:

  1. Have an angular 11 project (applies to other versions, too)
  2. In the project dir, make a run of $ ng update @angular/cli@12 fail for some dependency reasons
  3. fix the issue, rerun $ ng update @angular/cli@12 and get Package '@angular/cli' is already up to date. It basically forgets about the current project not being updated yet and the migration scripts it still needs to run:
$ cat package.json 
...
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^12.2.18",
    "@angular-devkit/core": "^16.2.4",
    "@angular/animations": "^11.2.14",
    "@angular/cli": "~11.2.19",
    "@angular/common": "^11.2.14",
    "@angular/compiler": "^11.2.14",
    "@angular/compiler-cli": "^11.2.14",
    "@angular/core": "^11.2.14",
    "@angular/forms": "^11.2.14",
    "@angular/language-service": "^11.2.14",
    "@angular/platform-browser": "^11.2.14",
    "@angular/platform-browser-dynamic": "^11.2.14",
    "@angular/router": "^11.2.14",
    "@types/extend": "^3.0.0",
    "@types/jasmine": "~3.6.0",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "^12.11.1",
    "@types/prismjs": "~1.4.18",
    "bowser": "^1.7.2",
    "codelyzer": "^6.0.0",
    "core-js": "^2.5.4",
    "date-fns": "2.0.0-alpha.1",
    "element-closest": "^2.0.2",
    "extend": "^3.0.1",
    "fs-extra": "^5.0.0",
    "is-ua-webview": "^1.0.0",
    "jasmine-core": "~3.8.0",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "~6.4.2",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "~3.0.2",
    "karma-jasmine": "~4.0.0",
    "karma-jasmine-html-reporter": "^1.5.0",
    "karma-min-reporter": "^0.1.0",
    "karma-phantomjs-launcher": "^1.0.4",
    "karma-remap-istanbul": "~0.4.0",
    "ng-packagr": "^11.2.4",
    "popper.js": "^1.14.0",
    "prismjs": "^1.29.0",
    "rxjs": "^6.6.7",
    "ts-node": "~5.0.1",
    "tslint": "~6.1.0",
    "typescript": "~4.0.8",
    "web-animations-js": "^2.3.2",
    "zone.js": "~0.10.2"
  }
}%     

Bonus: I think angular CLI is so excited to be updated globally (which makes no sense when just trying to upgrade a project) that it totally forgets to check if the angular project you're in right now actually needs an upgrade ?

$ ng version


Angular CLI: 12.2.18
Node: 16.20.2 (Unsupported)
Package Manager: npm 8.19.4
OS: darwin x64

Angular: 12.2.17
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1202.18
@angular-devkit/build-angular   12.2.18
@angular-devkit/core            16.2.4
@angular-devkit/schematics      16.2.4
@angular/cli                    12.2.18
@schematics/angular             12.2.18
ng-packagr                      12.2.7
rxjs                            6.6.7
typescript                      4.3.5

none of which actually applies to the project of course.

Minimal Reproduction

Repro:

  1. Have an angular 11 project (applies to other versions, too)
  2. In the project dir, make a run of $ ng update @angular/cli@12 fail for some dependency reasons
  3. fix the issue, rerun $ ng update @angular/cli@12 and get Package '@angular/cli' is already up to date. although

Exception or Error

Package '@angular/cli' is already up to date.

Your Environment

This was installed trying to upgrade the above mentioned project.


$ ng version


Angular CLI: 12.2.18
Node: 16.20.2 (Unsupported)
Package Manager: npm 8.19.4
OS: darwin x64

Angular: 12.2.17
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1202.18
@angular-devkit/build-angular   12.2.18
@angular-devkit/core            16.2.4
@angular-devkit/schematics      16.2.4
@angular/cli                    12.2.18
@schematics/angular             12.2.18
ng-packagr                      12.2.7
rxjs                            6.6.7
typescript                      4.3.5



### Anything else relevant?

_No response_

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions