Skip to content
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

Re-running migration produces "invalid version" error #14559

Closed
jonrimmer opened this issue May 29, 2019 · 11 comments · Fixed by #14569
Closed

Re-running migration produces "invalid version" error #14559

jonrimmer opened this issue May 29, 2019 · 11 comments · Fixed by #14569

Comments

@jonrimmer
Copy link

jonrimmer commented May 29, 2019

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

@alan-agius4
Copy link
Collaborator

alan-agius4 commented May 29, 2019

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

@alan-agius4 alan-agius4 added the needs: more info Reporter must clarify the issue label May 29, 2019
@jonrimmer
Copy link
Author

ng update --all --force

@alan-agius4
Copy link
Collaborator

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.

@alan-agius4
Copy link
Collaborator

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"

@filipesilva
Copy link
Contributor

We seem to have some problems running migration on Windows (#14565), together with migrations for @angular/core not running when you are already on a beta or rc (#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

@alan-agius4
Copy link
Collaborator

Another report of the invalid version error when using —-from 7 #14561 (comment)

@alan-agius4
Copy link
Collaborator

alan-agius4 commented May 29, 2019

@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' **

clydin added a commit to clydin/angular-cli that referenced this issue May 29, 2019
This implements the logic provided in the following link with the exception that the lower range is exclusive instead of inclusive.
https://github.com/npm/node-semver#hyphen-ranges-xyz---abc

Fixes angular#14559
@devversion
Copy link
Member

devversion commented May 30, 2019

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 b7fc612).

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

options.from = _formatVersion(options.from);
options.to = _formatVersion(options.to);

alexeagle pushed a commit that referenced this issue May 30, 2019
This implements the logic provided in the following link with the exception that the lower range is exclusive instead of inclusive.
https://github.com/npm/node-semver#hyphen-ranges-xyz---abc

Fixes #14559
alexeagle pushed a commit that referenced this issue May 30, 2019
This implements the logic provided in the following link with the exception that the lower range is exclusive instead of inclusive.
https://github.com/npm/node-semver#hyphen-ranges-xyz---abc

Fixes #14559
@kishore0207
Copy link

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.

@Jimit09
Copy link

Jimit09 commented Aug 1, 2019

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.

@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 Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants