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

Package reset halted due to encountering local changes #56

Open
evgeny-barinov opened this issue Mar 12, 2020 · 2 comments
Open

Package reset halted due to encountering local changes #56

evgeny-barinov opened this issue Mar 12, 2020 · 2 comments

Comments

@evgeny-barinov
Copy link

evgeny-barinov commented Mar 12, 2020

From time to time I catch this error while installing composer packages. So what can be a possible reason of this happening? Thanks!

[Vaimo\ComposerPatches\Exceptions\PackageResetException]
Package reset halted due to encountering local changes
@allanpaiste
Copy link
Contributor

allanpaiste commented Mar 12, 2020

This was included to avoid situations that could lead to uncommitted changes to be wiped when patch commands are used (note that the patch applier logic also triggers when a install/update event targets either directly or indirectly a package that has patches defined against it).

The way the patches are applied is based on the standard Composer behaviour of reinstalling a package which would mean that a user can potentially lose changes that they have made to the sub-components and their project, so this error/check has been put in place to avoid such unfortunate situations BUT it could also be caused by the dev-versioned package being targeted by some patch (in which case it'd be actually OK to reinstall it -- but there's no sophisticated logic behind the whole check to differentiate between the two situations).

You can force the reset in all such cases by using --force flag while using composer patch:<apply/redo/undo>.

If you'd want this to be the default behaviour on every composer event that includes patches, you can also add the following to your project's package.json:

{
  "extra": {
    "patcher": {
      "force-reset": true
    }
  }
}

@allanpaiste
Copy link
Contributor

One thing that could be done here would be to track the fingerprint of the whole code-base of the patched package to determine if changes introduced are from the patches.

Another thing that should be checked for is to see if there's a probability for a situation to occur where there are two patches against one dev-version package where first one introduces the code modifications and second one fails.

@allanpaiste allanpaiste added this to the 3.53.3 milestone Feb 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants