x
)
- [ ] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [x] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc
No, this issue only applies to updating from version 7 to 8.
I'm unable to update @angular/material
when following the update instructions for a basic application. After updating the project with ng update @angular/cli @angular/core
, I'm receiving an error when attempting to run ng update @angular/material
.
ng new update-test --routing --style scss
cd
into the app's root directory and add angular material ng add @angular/material
ng update @angular/cli @angular/core
ng update @angular/material
The error should appear after entering the command in step 5 and before the schematic executes.
Repository is not clean. Please commit or stash any changes before updating.
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ β³ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 8.0.0
Node: 12.3.1
OS: darwin x64
Angular: 8.0.0
... animations, 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
@angular/cdk 7.3.7
@angular/material 7.3.7
@ngtools/webpack 8.0.0
@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?
I was able to reproduce on both Windows 10 and OS X.
This is expected and intentional. The git repository has uncommitted changes. If the changes arenβt committed before the update then there would be a risk that the update may fail (or succeed but leave the application in a broken state) and there may be no easy way to revert the bad changes introduced by the update.
I have the same issue. And it happens cause my angular project is not in the main git folder. And there's nothing to commit in the entire folder.
FYI, there is an allow-dirty
flag to bypass the repo check.
ng update @angular/cli @angular/core --allow-dirty
@rodlourenco The next patch release will account for your use case and only consider files inside the Angular workspace.
FYI, there is an
allow-dirty
flag to bypass the repo check.ng update @angular/cli @angular/core --allow-dirty
This doesn't seem to exist anymore in 8.0.0, although it's still in their documentation, ng update --help
has no mention of it and I've tried --allow-dirty/--allowDirty
. I unfortunately had to commit and then undo that commit.
@cjonasw it was only introduced in 8.1.0-beta.0
and finally released in 8.1.0
.
Itβs also in 8.0.1+.
8.0.3+ has the fix for more complex git repositories that contain the Angular project in a nested directory.
I just updated to 8.1.1 from 7 and this message and stopping the update is a huge pain. Please make the need for --allow-dirty to go away. A simple message with y/n is good enough. Actually, the whole update process this time has been a train wreak of crashing updates. Not the place for that discussion here but it hasn't been this bad since RC days.
Why is this issue closed when it's not fixed?
I do not understand.
@dcolakchile it's unclear what you mean. https://github.com/angular/angular-cli/issues/14600#issuecomment-497513709 details how this is intended.
It would be nice if there was an angular.json
option to set your updates to always --allow-dirty
as I have to use it many times per week at this point. However, so far requests for that feature have not been met with much interest.
Or instead of saying "Please commit or stash any changes before updating."...which is untrue because I have nothing to commit or stash... display either how to actually resolve the issue (--allow-dirty) or where to go to find the correct information.
p.s. when using --allow-dirty, it suggested I need to use --force. When --allow-dirty is used, it correctly suggests how to resolve any blockers.
@clydin can we please reopen this and get information about the --allow-dirty
option added to the error message?
It would also be nice to add a workspace option to always allow dirty with ng update
.
The option is intentionally not mentioned as it is not the correct step to remedy the situation and should only be used in extreme situations. The proper remedy is already specified within the error message (Please commit or stash any changes before updating
). This will become even more relevant with 9.0 wherein each migration will be contained within a separate commit due to the larger volume and scope of the upcoming migrations.
As to the check itself, it is based on a call to git status
. If git is saying the repository is not clean, barring a defect in git's change tracking (which is unlikely), the repository is most likely not clean.
I have not yet encountered a situation where I want to make a commit for each migration. I generally have to run ng update @angular/cli
and then ng update @angular/material --allow-dirty
and then possibly one more update. I don't want to make separate commits per migration. I only want to commit after the migrations are done, the project is building, tests are passing, and any other manual fixes or adjustments need to be made.
Encouraging a behavior that is an opinion of correctness is fine, but forcing a behavior that people do not want to follow is ... unfortunate. There are more than one "right" way to do most things.
@clydin
The proper remedy is already specified within the error message (Please commit or stash any changes before updating).
I think half the issue with this message, from what I can tell, is the use of clean
, as an antonym of dirty
which is a pretty well understood term in Git:
that is, your modified tracked files and staged changes
In my situation, there are no files to commit or stash, as all the files are untracked:
$ find . -type f | grep -v -e node_modules/ -e .git/ | sort
./a
./b
./c
./module-one/.gitignore
./module-one/README.md
./module-one/angular.json
./module-one/browserslist
./module-one/package-lock.json
./module-one/package.json
./module-one/src/app/app.component.ts
./module-one/src/app/app.module.ts
./module-one/src/assets/.gitkeep
./module-one/src/environments/environment.prod.ts
./module-one/src/environments/environment.ts
./module-one/src/favicon.ico
./module-one/src/index.html
./module-one/src/main.ts
./module-one/src/polyfills.ts
./module-one/src/styles.css
./module-one/tsconfig.app.json
./module-one/tsconfig.json
./module-two/a
./module-two/b
./module-two/c
$ pushd module-one
$ git status --porcelain
?? b
?? c
?? module-two/b
?? module-two/c
$ git stash
No local changes to save
$ git commit
On branch master
Untracked files:
../b
../c
../module-two/b
../module-two/c
nothing added to commit but untracked files present
$ ng update --all true
Repository is not clean. Please commit or stash any changes before updating.
What's more, there are no untracked files (let alone modified files) in the Angular application directory.
The check is a call to βgit status βporcelainβ and a filter of any files that are outside the workspace root. If git status says the repository is dirty then it is considered not clean. Doing any kind of major change in such a state is not recommended.
https://mirrors.edge.kernel.org/pub/software/scm/git/docs/gitglossary.html#def_dirty
@clydin from your link:
A working tree is said to be "dirty" if it contains modifications which have not been committed to the current branch.
The working tree doesn't contain any modifications, just untracked files.
Also, this doesn't really address the logic behind requiring no untracked files anywhere within the git working tree, if the Angular project is under a subdirectory. Surely the update can be performed without considering anything outside the Angular project?
@clydin in case you were interested, this is the method I used to get the directory structure above, and to illustrate the state that the repository is in:
pushd $(mktemp -d)
git init .
touch a b c
ng new module-one --minimal --style css --routing false
mkdir module-two
touch module-two/{a,b,c}
git add a module-one module-two/a
git commit -m 'initial'
pushd module-one
ng update --all true
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._
Most helpful comment
FYI, there is an
allow-dirty
flag to bypass the repo check.