monodeploy icon indicating copy to clipboard operation
monodeploy copied to clipboard

cannot pull with rebase: You have unstaged changes.

Open gabormagyar opened this issue 2 years ago • 5 comments

Describe the bug

The error:

➤ YN0001: │ Error: Executing 'git pull --rebase --no-verify origin' failed with code: 128

error: cannot pull with rebase: You have unstaged changes.
error: please commit or stash them.

This happens after monodeploy's yarn install step, which shouldn't change any files that aren't explicitly committed (changelog, package.json, yarn.lock). However in this instance monodeploy's yarn install renamed the two typescript patch files in yarn cache:

Screenshot 2022-09-12 at 12 26 01

If I run yarn install manually the files change back to what they were originally.

I believe this happens because of a mismatch between yarn versions. The install that monodeploy runs creates different TS patches to the one I run. This means monodeploy fails on the changed files when it tries to push.

Updating monodeploy to the latest version fixes the issue.

Please investigate further and figure out what could be done to make the failure easier to understand and fix. Hopefully this could be detected earlier on with a clear error message. Also the publish already happened at this point, so only the commit and push is what fails, which causes an inconsistent state for the package.

Please edit the issue title accordingly (or close).

Environment:

  • Monodeploy Version: 3.0.2
  • Yarn Version: 3.2.3
    • Yarn module linker: pnp
  • Node Version: v16.17.0
  • Git Version: 2.33.1

Full(er) log:

➜ yarn monodeploy 
➤ YN0000: ┌ Determine New Versions
[...]
➤ YN0000: └ Completed
➤ YN0000: ┌ Determine Git Tags
➤ YN0000: └ Completed
➤ YN0000: ┌ Generating Changeset
➤ YN0000: └ Completed
➤ YN0000: ┌ Fetching Workspace Information
➤ YN0000: └ Completed
➤ YN0000: ┌ Updating Changelog
[...]
➤ YN0000: └ Completed
➤ YN0000: ┌ Patching Package Manifests
➤ YN0000: └ Completed
➤ YN0000: ┌ Publishing Packages
[...]
➤ YN0000: │ [Publish] 'package-name' published.
➤ YN0000: └ Completed in 20s 43ms
➤ YN0000: ┌ Updating Project State
➤ YN0000: │ ┌ Resolution step
[...]
➤ YN0000: │ └ Completed in 0s 264ms
➤ YN0000: │ ┌ Fetch step
➤ YN0013: │ │ typescript@patch:typescript@npm%3A4.6.4#~builtin<compat/typescript>::version=4.6.4&hash=7ad353 can't be found in the cache and will be fetched from the disk
➤ YN0013: │ │ typescript@patch:typescript@npm%3A4.7.3#~builtin<compat/typescript>::version=4.7.3&hash=7ad353 can't be found in the cache and will be fetched from the disk
➤ YN0019: │ │ typescript-patch-363d50fa2f-1cb434fbc6.zip appears to be unused - removing
➤ YN0019: │ │ typescript-patch-410f671920-137d18a77f.zip appears to be unused - removing
➤ YN0000: │ └ Completed in 0s 521ms
➤ YN0000: │ ┌ Link step
[...]
➤ YN0000: │ │ ESM support for PnP uses the experimental loader API and is therefore experimental
➤ YN0000: │ └ Completed
➤ YN0000: └ Completed in 1s 53ms
➤ YN0000: ┌ Committing Changes
➤ YN0000: │ [Tag] @[email protected]
➤ YN0001: │ Error: Executing 'git pull --rebase --no-verify origin' failed with code: 128

error: cannot pull with rebase: You have unstaged changes.
error: please commit or stash them.

    at [...]
➤ YN0000: └ Completed in 0s 309ms
➤ YN0000: ┌ Cleaning Up
➤ YN0000: └ Completed
➤ YN0000: Failed with errors in 25s 411ms
Error: Monodeploy failed

gabormagyar avatar Sep 12 '22 10:09 gabormagyar

This happens because of a bad release of @yarnpkg/plugin-compat. There's typically a way to force the version using a yarn resolution but we can also fix it from within monodeploy directly. I'll take a look.

For reference, this has happened before: https://discord.com/channels/226791405589233664/654372321225605128/924411017746866236

noahnu avatar Sep 12 '22 11:09 noahnu

I believe yarn 3.2.3 is bundled with plugin-compat 3.1.5 but I'm guessing you have 3.1.4 installed. You can verify this by running yarn info -AR @yarnpkg/plugin-compat. If this is the case, then to fix this, in your project run:

 yarn up @yarnpkg/plugin-compat -R

noahnu avatar Sep 12 '22 13:09 noahnu

Similar issues keep happening from time to time with monodeploy updates. I think it should be much clearer in the docs or even in the command output what versions of yarn a certain version of monodeploy is compatible with.

gabormagyar avatar Dec 13 '22 10:12 gabormagyar

I have a few ideas to fix this, just need to find some time (and my open source focus right now is on wrapping up the next major version of my syrupy python project -- will come back to solve this once that's done). I'm thinking of offering a yarn plugin version of monodeploy so we have consistent versions of the yarn packages.

The version inconsistency is ultimately an issue with how yarn releases updates, so there's an opportunity to fix this upstream as well.

noahnu avatar Dec 13 '22 12:12 noahnu

Monodeploy has been forked under a new name Monoweave. I've copied your issue over and will address it in the monoweave project.

https://github.com/monoweave/monoweave/issues/81

noahnu avatar Mar 31 '24 19:03 noahnu