Running ng version
outside an Angular project has confusing output
#16549
Labels
2022Q3 Fixit
Candidates for the Q3 2022 fix-it
area: angular/cli
freq1: low
Only reported by a handful of users who observe it rarely
severity1: confusing
type: bug/fix
Milestone
🐞 Bug report
Command
Is this a regression?
No
Description
I have a monorepo where I am adding an Angular project. As a result, it exists in a subdirectory. Since many tools (such as
ng
) expect the project to be the working directory, I often use the pattern(cd path/to/subproject/ && run some tool)
. The subshell means I'm returned back to my original directory.This pattern does not play well with
ng version
andng update
. I was trying to update to version 9 prerelease and saw the following:This was confusing and made me think the update failed, however the update was actually fine. My mistake here was running
ng version
in the root of my monorepo, rather than the Angular project. After noticing this I tried:Which is what I expected post-update.
IMHO this dichotomy is confusing. When the user is in an Angular project, it lists versions of that project. When outside an Angular project, it lists the global versions and it is very easy to look at the wrong one.
I'm not sure what the ideal solution to this problem would be. There could be two different commands, such as an
ng global-version
andng project-version
, but this might add too much additional complexity to be worth it. Maybe the output could simply be updated to be more clear? Such as having some big red text saying "No Angular project detected at $PWD"?The text was updated successfully, but these errors were encountered: