Angular-cli: Re-running migration produces "invalid version" error

Created on 29 May 2019  Β·  11Comments  Β·  Source: angular/angular-cli

🐞 Bug report

Command (mark with an x)


- [ ] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [x] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Is this a regression?

Yes. Previously worked with pre-V8 CLI.

Description

If the migration from v7 to v8 fails, the CLI prints the following:

Migration can be rerun with: "ng update @angular/core --from 7 --to 8 --migrate-only"

Trying to run this command after fixing whatever was wrong does not work.

πŸ”₯ Exception or Error

Using package manager: 'npm'
Collecting installed dependencies...
Found 77 dependencies.
Invalid Version: 7

🌍 Your Environment

Angular CLI: 8.0.0
Node: 11.10.1
OS: darwin x64
Angular: 8.0.0
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, language-service, platform-browser
... platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.800.0
@angular-devkit/build-angular     0.800.0
@angular-devkit/build-optimizer   0.800.0
@angular-devkit/build-webpack     0.800.0
@angular-devkit/core              8.0.0
@angular-devkit/schematics        8.0.0
@ngtools/webpack                  8.0.0
@nguniversal/express-engine       7.1.1
@schematics/angular               8.0.0
@schematics/update                0.800.0
rxjs                              6.5.2
typescript                        3.4.5
webpack                           4.30.0

Anything else relevant?

schematicupdate high regression bufix

Most helpful comment

Increasing the priority as in the @angular/core migration schematics if it fail its will print Migration can be rerun with: "ng update @angular/core --from 7 --to 8 --migrate-only"

All 11 comments

Hi, can you please provide the original command that you used to update?

ng update --all --force

The original issue seems to be that the from and to versions should be full semver versions example 7.0.0 and 8.0.0.

Ie ng update @angular/core --from 7.0.0 --to 8.0.0 --migrate-only instead of ng update @angular/core --from 7 --to 8 --migrate-only

We should probably handle both.

Increasing the priority as in the @angular/core migration schematics if it fail its will print Migration can be rerun with: "ng update @angular/core --from 7 --to 8 --migrate-only"

We seem to have some problems running migration on Windows (https://github.com/angular/angular-cli/issues/14565), together with migrations for @angular/core not running when you are already on a beta or rc (https://github.com/angular/angular-cli/issues/14553).

Here is a workaround for now:

  • use 8.0.0 in the global install: npm i -g @angular/[email protected]
  • locally use CLI 8.0.0-rc.0: npm install @angular/[email protected] --save-exact --save-dev
  • commit to git
  • try to update again, the update should work now ng update @angular/core --from 7 --to 8 --migrate-only
  • go back to CLI 8.0.0 npm install @angular/[email protected] --save-dev

Another report of the invalid version error when using β€”-from 7 https://github.com/angular/angular-cli/issues/14561#issuecomment-496942757

@filipesilva I don't think this is related to what you mentioned above, this issue is not on Windows and migrations are being run.

The problem here is that ng update @angular/core --from 7 --to 8 --migrate-only errors out while ng update @angular/core --from 7.0.0 --to 8.0.0 --migrate-only works as expected.

/workspace/viewChild-test-ng8 $ yarn ng update @angular/core --from 7 --to 8 --migrate-only
yarn run v1.16.0
$ ng update @angular/core --from 7 --to 8 --migrate-only
Using package manager: 'npm'
Collecting installed dependencies...
Found 30 dependencies.
Invalid Version: 7

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. 

/workspace/viewChild-test-ng8 $ yarn ng update @angular/core --from 7.0.0 --to 8.0.0 --migrate-only
yarn run v1.16.0
$ ng update @angular/core --from 7.0.0 --to 8.0.0 --migrate-only
Using package manager: 'npm'
Collecting installed dependencies...
Found 30 dependencies.
    ** Executing migrations for package '@angular/core' **

We should note that this is indeed a regression as it previously worked with pre-V8 CLI versions but broke accidentally with V8 as there was some logic refactoring for the --migrate-only flag (see https://github.com/angular/angular-cli/commit/b7fc6125e536c9a94250b901ed925a6cb92dae76).

Previously the --from and --to options were working that way since they followed the Semver rules. See:

https://github.com/angular/angular-cli/blob/37debd7105eb499adf8268ade4ad8b33f6153f24/packages/schematics/update/update/index.ts#L809-L810

Am updating the angular 7 to 8, after updating the ng update @angular/cli @angular/core command updated successfully,
but after updating the material through ng update @angular/material entered, then i got the error.
Repository is not clean. Please commit or stash any changes before updating.

Am updating the angular 7 to 8, after updating the ng update @angular/cli @angular/core command updated successfully,
but after updating the material through ng update @angular/material entered, then i got the error.
Repository is not clean. Please commit or stash any changes before updating.

1st you need to commit the changes done from ng update @angular/cli @angular/core and then you can trye updating angular material.

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

Was this page helpful?
0 / 5 - 0 ratings