Giter Site home page Giter Site logo

Patching doesn't work about patch-package HOT 32 CLOSED

migzai avatar migzai commented on May 4, 2024
Patching doesn't work

from patch-package.

Comments (32)

migzai avatar migzai commented on May 4, 2024 1

Here's the output of patch -p1 -i patches/react-native-ssdp+2.7.5.patch --verbose --dry-run

Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff --git a/node_modules/react-native-ssdp/lib/client.js b/node_modules/react-native-ssdp/lib/client.js
|index 942b3f0..74c429d 100644
|--- a/node_modules/react-native-ssdp/lib/client.js
|+++ b/node_modules/react-native-ssdp/lib/client.js
--------------------------
Patching file node_modules/react-native-ssdp/lib/client.js using Plan A...
Hunk #1 succeeded at 50.
Hmm...  The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff --git a/node_modules/react-native-ssdp/lib/index.js b/node_modules/react-native-ssdp/lib/index.js
|index b90feb7..39905be 100644
|--- a/node_modules/react-native-ssdp/lib/index.js
|+++ b/node_modules/react-native-ssdp/lib/index.js
--------------------------
Patching file node_modules/react-native-ssdp/lib/index.js using Plan A...
Hunk #1 succeeded at 11.
Hunk #2 succeeded at 135.
Hmm...  The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff --git a/node_modules/react-native-ssdp/node_modules/react-native-udp/UdpSocket.js b/node_modules/react-native-ssdp/node_modules/react-native-udp/UdpSocket.js
|index 73dca9f..d30bcd1 100644
|--- a/node_modules/react-native-ssdp/node_modules/react-native-udp/UdpSocket.js
|+++ b/node_modules/react-native-ssdp/node_modules/react-native-udp/UdpSocket.js
--------------------------
Patching file node_modules/react-native-ssdp/node_modules/react-native-udp/UdpSocket.js using Plan A...
Hunk #1 succeeded at 83.
done

from patch-package.

ds300 avatar ds300 commented on May 4, 2024

Thanks for the report. Do you mind sharing your patch files so I can debug this?

EDIT

If you've landed here from google, try the v6 pre release branches patch-package@beta

from patch-package.

migzai avatar migzai commented on May 4, 2024

Sure. Attached the patch file.

react-native-ssdp+2.7.5.zip

from patch-package.

ds300 avatar ds300 commented on May 4, 2024

Cool thanks. I'm quite busy until Saturday but will try to make some time to look at this before then, it's a high priority for me.

from patch-package.

ds300 avatar ds300 commented on May 4, 2024

Looks like it might be related to patching nested dependencies.

@migzai can you run

patch -p1 -i patches/react-native-ssdp+2.7.5.patch --verbose --dry-run

on MacOS and paste the output here please?

from patch-package.

ds300 avatar ds300 commented on May 4, 2024

Thanks. Looks fine. Must be git-specific then. Any chance you could share your repo with me? Would make it a lot easier to debug.

from patch-package.

migzai avatar migzai commented on May 4, 2024

Attached a test case..

test.zip

from patch-package.

migzai avatar migzai commented on May 4, 2024

Yes this happens if the project uses git and the .git folder isn't at the same level as the patches directory.

from patch-package.

ds300 avatar ds300 commented on May 4, 2024

Can confirm. Thanks.

This project was using the unix patch command up until recently. We switched to git apply for the windows support, but it seems that introduces its own problems. On initial inspection of git-apply, there doesn't seem to be a cli option to work around this. Will have to look into some other option for windows.

As a temporary workaround, version 3.3.1 should work on windows with git bash.

from patch-package.

ds300 avatar ds300 commented on May 4, 2024

I think I've fixed this now in version 3.3.4, by using the --unsafe-paths option to git apply Could you check it works on your end, @migzai ? I don't have Windows testing facilities.

from patch-package.

migzai avatar migzai commented on May 4, 2024

I can confirm that this doesn't work on Windows still. Git is 'Skipping patches'.

from patch-package.

ds300 avatar ds300 commented on May 4, 2024

πŸ’© I'll look in to this some more on saturday

from patch-package.

migzai avatar migzai commented on May 4, 2024

Hi. Any progress on this so far? Thanks

from patch-package.

ds300 avatar ds300 commented on May 4, 2024

Sorry I didn't make any useful progress on it on saturday. I'll have some time this evening to try again.

from patch-package.

ds300 avatar ds300 commented on May 4, 2024

Progress update: this is definitely an inconsistency in the way git apply works on different platforms. Windows git ignores the facet of --unsafe-paths that says the files don't have to be in the index, and will silently skip them if it can't find them in the index. Apparently there is an undocumented --no-index flag, but that doesn't seem to help either, at least on the windows machine I'm using. I'm going to do two things:

  • check for silently skipped files
  • if files were silently skipped and we're running on windows and the git root folder is not the same as the package.json, make a copy of the patch file with the named file paths resolved relative to the root of the git repo, and apply that instead.
  • otherwise throw an error

This should be a forwards-compatible workaround, in case windows git ever aligns its behaviour across platforms.

from patch-package.

ds300 avatar ds300 commented on May 4, 2024

πŸ˜• Now I'm seeing the same behaviour on MacOS so it must be that my testing env was not set up properly when I thought I'd fixed it last week. At least that means git is consistent :)

from patch-package.

ds300 avatar ds300 commented on May 4, 2024

@migzai Pretty sure this is fixed now. Tested on windows and everything! Do you mind confirming 3.3.5 solves your issue?

from patch-package.

migzai avatar migzai commented on May 4, 2024

Hi. Just tested 3.3.5 on Windows. Still getting the same behavior as before..

from patch-package.

ds300 avatar ds300 commented on May 4, 2024

😧 Even with the test repo you attached?

from patch-package.

migzai avatar migzai commented on May 4, 2024

Yes..

from patch-package.

ds300 avatar ds300 commented on May 4, 2024

My apologies. I'll double check my tests next time I have access to the windows laptop, which will be on Sunday. Sorry again for the inconvenience. Could have sworn this was working πŸ˜•

from patch-package.

calvin337 avatar calvin337 commented on May 4, 2024

Same issue here, works on node modules in the same folder as where the .git folder is but doesn't work for any sub-directories.

from patch-package.

ds300 avatar ds300 commented on May 4, 2024

Thanks @calvin337 β€” is that also for windows?

from patch-package.

calvin337 avatar calvin337 commented on May 4, 2024

Yeah also for Windows, it works fine on Mac.

from patch-package.

ds300 avatar ds300 commented on May 4, 2024

@migzai @calvin337 just released 3.3.6 - again pretty sure this fixes the issue. Third time's a charm 🀞 :D

from patch-package.

migzai avatar migzai commented on May 4, 2024

I can confirm that this now works on Windows. Thanks! There's an issue though on Linux when I attempt to run patch-package:

Patch was made for version 0.10.8
Meanwhile node_modules/react-native-fetch-blob is version 0.10.8

Something not logical going on and the patch-package fails with exit code 1.
patch-package.zip

from patch-package.

ds300 avatar ds300 commented on May 4, 2024

Thanks for the log. I'll take a look tonight.

from patch-package.

ds300 avatar ds300 commented on May 4, 2024

Can't reproduce this issue on ubuntu with the test repo. @migzai any chance you could zip and attach the patch file for react-native-fetch-blob?

from patch-package.

migzai avatar migzai commented on May 4, 2024

There you go.
react-native-fetch-blob+0.10.8.zip

from patch-package.

ds300 avatar ds300 commented on May 4, 2024

Thanks. Still can't reproduce the issue with your test repo, unfortunately. I added the patch file into the patches directory, upgraded patch-package, and added react-native-fetch-blob. The patch was applied as expected on Ubuntu 17.04 with Git 2.11.0

Which linux/git are you on? Did you try deleting node_modules and trying again? Any other help you could give to reproduce the issue would be most appreciated πŸ™‡

from patch-package.

ds300 avatar ds300 commented on May 4, 2024

@migzai Not sure if you're still suffering from this problem, but thanks to #21 we figured out that git can enforce particular whitespace rules for patch files, which should make them work across platforms seamlessly. 🀞

All you need to do is add one line in .gitattributes, see the linked issue for details. Let me know if that solves your problem, or maybe you're not using patch-package anymore in which case feel free to ignore this and I'll close the issue due to inactivity in a few days.

Thanks for your help and collaboration!

from patch-package.

ds300 avatar ds300 commented on May 4, 2024

Closing due to inactivity, as discussed. Please re-open if you find the problem has not been solved.

from patch-package.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.