-
Notifications
You must be signed in to change notification settings - Fork 12k
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
A silent error is thrown in AddCommandModule.builder
, when passing a version to the command ng add @my/lib@<version>
#27766
Labels
area: @angular/cli
freq1: low
Only reported by a handful of users who observe it rarely
severity3: broken
type: bug/fix
Comments
Platonn
changed the title
A silent error is thrown in
A silent error is thrown in Jun 3, 2024
AddCommandModule.builder
, when passing a version to the command ng add @my-lib@<version>
AddCommandModule.builder
, when passing a version to the command ng add @my/lib@<version>
Platonn
added a commit
to Platonn/angular-cli
that referenced
this issue
Jun 3, 2024
…when a version is passed to `ng add <package>@<version>` This commit fixes the method `AddCommandModule.getCollectionName()`, so it now returns only the package name, but remove the specified version (if present). Previously, a `@<version>` specified in the const `collectionName` was causing a (silenced) error during the invocation of `workflow.engine.createCollection(collectionName)`, which lead to skipping eventually the invocation of the method `this.addSchemaOptionsToCommand()` in the try/catch block. fixes angular#27766
Platonn
added a commit
to Platonn/angular-cli
that referenced
this issue
Jun 3, 2024
…when a version is passed to `ng add <package>@<version>` This commit fixes the method `AddCommandModule.getCollectionName()`, so it now returns only the package name, but remove the specified version (if present). Previously, a `@<version>` specified in the const `collectionName` was causing a (silenced) error during the invocation of `workflow.engine.createCollection(collectionName)`, which lead to skipping eventually the invocation of the method `this.addSchemaOptionsToCommand()` in the try/catch block. fixes angular#27766
13 tasks
Platonn
added a commit
to Platonn/angular-cli
that referenced
this issue
Jun 3, 2024
…when a version is passed to `ng add <package>@<version>` This commit fixes the method `AddCommandModule.getCollectionName()`, so it now returns only the package name, but remove the specified version (if present). Previously, a `@<version>` specified in the const `collectionName` was causing a (silenced) error during the invocation of `workflow.engine.createCollection(collectionName)`, which lead to skipping eventually the invocation of the method `this.addSchemaOptionsToCommand()` in the try/catch block. fixes angular#27766
alan-agius4
added
type: bug/fix
freq1: low
Only reported by a handful of users who observe it rarely
severity3: broken
area: @angular/cli
labels
Jun 3, 2024
Platonn
added a commit
to Platonn/angular-cli
that referenced
this issue
Jun 3, 2024
…when a version is passed to `ng add <package>@<version>` This commit fixes the method `AddCommandModule.getCollectionName()`, so it now returns only the package name, but remove the specified version (if present). Previously, a `@<version>` specified in the const `collectionName` was causing a (silenced) error during the invocation of `workflow.engine.createCollection(collectionName)`, which lead to skipping eventually the invocation of the method `this.addSchemaOptionsToCommand()` in the try/catch block. fixes angular#27766
Platonn
added a commit
to Platonn/angular-cli
that referenced
this issue
Jun 4, 2024
…when a version is passed to `ng add <package>@<version>` This commit fixes the method `AddCommandModule.getCollectionName()`, so it now returns only the package name, but remove the specified version (if present). Previously, a `@<version>` specified in the const `collectionName` was causing a (silenced) error during the invocation of `workflow.engine.createCollection(collectionName)`, which lead to skipping eventually the invocation of the method `this.addSchemaOptionsToCommand()` in the try/catch block. fixes angular#27766
dgp1130
pushed a commit
that referenced
this issue
Jun 4, 2024
…when a version is passed to `ng add <package>@<version>` This commit fixes the method `AddCommandModule.getCollectionName()`, so it now returns only the package name, but remove the specified version (if present). Previously, a `@<version>` specified in the const `collectionName` was causing a (silenced) error during the invocation of `workflow.engine.createCollection(collectionName)`, which lead to skipping eventually the invocation of the method `this.addSchemaOptionsToCommand()` in the try/catch block. fixes #27766
dgp1130
pushed a commit
that referenced
this issue
Jun 4, 2024
…when a version is passed to `ng add <package>@<version>` This commit fixes the method `AddCommandModule.getCollectionName()`, so it now returns only the package name, but remove the specified version (if present). Previously, a `@<version>` specified in the const `collectionName` was causing a (silenced) error during the invocation of `workflow.engine.createCollection(collectionName)`, which lead to skipping eventually the invocation of the method `this.addSchemaOptionsToCommand()` in the try/catch block. fixes #27766 (cherry picked from commit ce8b5a3)
celestius0
pushed a commit
to celestius0/angular-cli
that referenced
this issue
Jun 5, 2024
…when a version is passed to `ng add <package>@<version>` This commit fixes the method `AddCommandModule.getCollectionName()`, so it now returns only the package name, but remove the specified version (if present). Previously, a `@<version>` specified in the const `collectionName` was causing a (silenced) error during the invocation of `workflow.engine.createCollection(collectionName)`, which lead to skipping eventually the invocation of the method `this.addSchemaOptionsToCommand()` in the try/catch block. fixes angular#27766
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
area: @angular/cli
freq1: low
Only reported by a handful of users who observe it rarely
severity3: broken
type: bug/fix
Command
add
Is this a regression?
The previous version in which this bug was not present was
No response
Description
Error
An exception is thrown during the method createCollection(), when the
collectionName
contains a@<version>
, e.g.ng add @my/[email protected]
.Negative consequences
The consequence is that the custom schematics' schema is not applied for parsing, i.e. the method addSchemaOptionsToCommand() is skipped, becasue of the thrown exception
And btw. the later this exception is ignored here.
Why it happens (internal Angular CLI code)
The error happens becasue eventually this line throws an error, becasue there is no such a directory like
node_modules/@my/[email protected]
, but onlynode_modules/@my/lib
Because an error is thrown, a custom schema.json is not applied for parsing the arguments then.
Idea of a fix:
Before passing the
collectionName
as an argument to thecreateCollection()
method, we could first extract any versions from it, e.g. by passing it throughnpa from 'npm-package-arg'
, e.g.:Additional notes
ng add @my/[email protected]
- causes errorng add @my/lib@
(with just@
) - also causes errorng add @my/lib
(nothing after the package's name) - doesn't cause errorMinimal Reproduction
Create a fresh angular 17 app
In VSCode add a
console.error({error})
in the AngularCLI's filenode_modules/@angular/cli/src/commands/add/cli.js
in line 80 (inside thiscatch
block):angular-cli/packages/angular/cli/src/commands/add/cli.ts
Lines 102 to 106 in ea843eb
see example:
(run
npm install @my/lib
- to mitigate the bug Schematic with multi select x-promt errors when using command line parameter: 'path ".foo" should be array' #16320 - but ideally this step shouldn't be needed when this other bug is fixed)run
ng add @my/library@<with-version-here>
See an error in the console
error: CollectionCannotBeResolvedException [Error]: Collection "@my/[email protected]" cannot be resolved.
Your Environment
Anything else relevant?
No response
The text was updated successfully, but these errors were encountered: