Getting errors when patching a npm package - patch

when I patch a dependency like this:
package.json:
"dependencies":
"react-native-webview": "patch:react-native-webview#11.0.3#scripts/patches/react-native-webview+11.0.3.patch",
...
patches/react-native-webview+11.0.3.patch:
diff --git a/apple/RNCWebView.m b/apple/RNCWebView.m
index ff9ff9e0..dfea91a8 100644
--- a/apple/RNCWebView.m
+++ b/apple/RNCWebView.m
## -194,12 +194,18 ## - (void)dealloc
...
everything works fine when I install things locally using yarn or yarn install. The patch gets applied, and there are no errors.
However, when things go into CI, I get an error like the following:
**ERROR** Failed to apply patch for package react-native-webview at path
node_modules/react-native-webview
This error was caused because patch-package cannot apply the following patch file:
patches/react-native-webview+11.0.3.patch
Try removing node_modules and trying again. If that doesn't work, maybe there was
an accidental change made to the patch file? Try recreating it by manually
editing the appropriate files and running:
patch-package react-native-webview
If that doesn't work, then it's a bug in patch-package, so please submit a bug
report. Thanks!
https://github.com/ds300/patch-package/issues
Things don't get better if I change the patch to use paths like a/node_modules/react-native-webview/apple/RNCWebView.m. I then get an error like
➤ YN0001: │ Error: react-native-webview#patch:react-native-webview#npm%3A11.0.3#../../scripts/patches/react-native-webview+11.0.3.patch::version=11.0.3&hash=d13297&locator=proj-core%40workspace%3Alib%2Fproj-core: ENOENT: no such file or directory, lstat '/node_modules/react-native-webview/node_modules/react-native-webview/apple/RNCWebView.m'
at rn (/home/user/dev/proj-client/.yarn/releases/yarn-3.0.0.cjs:172:9625)
at kn (/home/user/dev/proj-client/.yarn/releases/yarn-3.0.0.cjs:172:9889)
at Qr.resolveFilename (/home/user/dev/proj-client/.yarn/releases/yarn-3.0.0.cjs:177:21594)
at Qr.resolveFilename (/home/user/dev/proj-client/.yarn/releases/yarn-3.0.0.cjs:177:21498)
at Qr.resolveFilename (/home/user/dev/proj-client/.yarn/releases/yarn-3.0.0.cjs:177:21498)
at Qr.lstatSync (/home/user/dev/proj-client/.yarn/releases/yarn-3.0.0.cjs:177:18712)
at Qr.lstatPromise (/home/user/dev/proj-client/.yarn/releases/yarn-3.0.0.cjs:177:18671)
at yt.lstatPromise (/home/user/dev/proj-client/.yarn/releases/yarn-3.0.0.cjs:177:34701)
at Zu (/home/user/dev/proj-client/.yarn/releases/yarn-3.0.0.cjs:578:7908)
at YB (/home/user/dev/proj-client/.yarn/releases/yarn-3.0.0.cjs:580:184)

The problem here is that you're using two different tools to patch the npm package, and using a different one locally than in CI:
patch-package as a post-install script (if you check the "postinstall" entry in your package.json, you'll see something like patch-package --patch-dir ./scripts/patches)
yarn's built-in package patching thing, which uses patch: in package.json.
However, they work differently:
patch-package
yarn's patch:
applies the patch from the project root, so you need to include node_modules/package-name in the diff.
applies the patch from the package install directory, so you don't need to do that
requires that the patch be named package-name+version.patch
doesn't require any specific naming
The solution here is to pick one, and to change the patch to work with that system. So, for example, if you rename the file to remove the +version, you'll be able to move forward using just yarn's patch:.

I don't know if anyone still looks up for this issue.
My issue was the difference of resolved version in yarn.lock.
I had a different package.json versions in my case, and i copied the code and it didn't work because the yarn.lock was already generated.
I just copied over the old yarn file and it worked perfectly.
For instance, my yarn.lock looked like this
I changed it to match the correct version

I make downgrade:
"patch-package": "^5.0.0"

Related

Julia: Use an older version of a package

I am really new to Julia and confused about using an old version of the SISL Vec package.
I am trying to setup ngsim_env and their instructions require you to use an older v0.1.0 of Vec. But, when I followed the instructions to install the Vec package and then checkout the v0.1.0 tag it didn't work.
Here's what I did
$ julia ../build.jl for some package which includes this block
packages = keys(Pkg.installed())
if !in("Vec", packages)
Pkg.clone("https://github.com/tawheeler/Vec.jl.git")
end
Note: This git URL actually goes to the SISL Vec page.
cd ~/.julia/packages/Vec
git fetch tags
git checkout v0.1.0
I did a bunch of other installations with many other packages. At some point I noticed that there is a package ~/.julia/dev/Vec and ~/.julia/packages/Vec. The one in dev has the correct v0.1.0 code and the one in packages has the newer wrong code. When I tried to use other packages that needed the older Vec they were throwing errors and the paths were to files in the packages directory.
I tried Pkg.rm("Vec"). This did something to the project manifest. After nothing worked, every package would throw errors like KeyError: key "Vec" not found and Pkg.add("Vec") nor original Vec installation helped. I even tried removing both the Vec directories from ~/.julia but that didn't help.
I guess a big question is why does Julia put some packages into packages/ and others into dev/ and how to control which one's get used if the same package appears in both places like Vec is.
Would greatly appreciate any assistance, totally confused.
The dev command fetches a full clone of the package to ~/.julia/dev/
via the docs. The only things I have in my dev directory there are the ones I am developing on my own.
I think that triggered when you did a check out manually with git checkout.
Accordingly:
to stop tracking a path and use the registered version again, use free
Try deleting the packages, and whipping mentions of Vec.jl from your manifest:
(v1.0) pkg> rm Vec
(v1.0) pkg> add https://github.com/tawheeler/Vec.jl.git#0.1.0
In general, try using Pkg when possible, cause it does a lot of house keeping magic in the back
(Also, the repl interface with pkg makes everything easier, so hit ] from a blank julia> to get there. And a quick Pkg.status() or ] st will show you what youre tracking and whats in dev and what version you have pinned, etc.)

Force sbt to reload whole build definition

sbt.version 0.13.15
Question:
How can I force sbt to reload and recompile all build definition regardless whether they are changed or not?
The story:
I have a multiproject build consiting of multiple sbt and scala files. When I first loaded the project (I am not an author) by sbt -v in console I got a list of deprecated warnings (mainly operators like <<= <+= <++=). I want to fix all these but now when I start sbt -v again I do not get these warnings any more. Not even after reload.
I tried to modify build file (removing import) and reloading then. It showed me errors caused by removed import but no warnings. After fixing import back it showed no warnings still.
Only way I was able to see the list again was to change build file in a way which directly affects build definition and reload it then...
Bottom line
So yes I can edit every single sbt file and reload it then. But I wonder there must be a better way. There must be a way how to either force-reload whole build definition or recall that list of warnings somehow.
Thanks for ideas on this!
I found out that compiled build definition is stored in project/target. So to achieve what I want it is enough to remove this dir and then reload. It's not a command from sbt but it works.

WinPython with PyQt5

I'm trying to get PyQt5 working with WinPython. PyQt5 comes with a readme file for installation, and I have unsuccessfully tried a few combinations of what I thought the first part of the readme tells me to do.
I have:
Windows 7 Home Premium 64-bit
WinPython-64bit-2.7.9.1
Qt 5.4
PyQt-gpl-5.4
PyQt-gpl-5.4 is in the folder (only partially sure that this is where I should have put it)
C:\WinPython-64bit-2.7.9.1\python-2.7.9.amd64\Lib\site-packages\PyQt-gpl-5.4
My current attempt at getting everything working is: I'm trying to run the configure.py file in PyQt-gpl-5.4, but when I do so I consistently get the following error:
Error: PyQt5 requires Qt v5.0 or later. You seem to be using v4.8.6.
Make sure the correct version of qmake is on your PATH.
What I think is the required version of qmake being referred to is in the folder
C:\Qt\5.4\mingw491_32\bin
However, I have no idea how to fix the error by adding the qmake in this folder to PATH. My most recent attempt was to add the folder using Spyder's Tools->PYTHONPATH manager, but this made no difference. I also tried adding it using sys.path.append('C:\Qt\5.4\mingw491_32\bin'), but this didn't work either. I have since removed the folder name from both of these locations.
How do I get PyQt5 working with WinPython-64bit-2.7.9.1, or I think equivalently, how to I get the configure.py file in the PyQt-gpl-5.4 folder to run?
Thanks.
You definitely don't want the source code (i.e. PyQt-gpl-5.4) in the site-packages folder, because that's where the compiled modules will end up. Instead, it should just go in a temporary folder whilst you compile it.
When you run configure.py, you must take care to use the executable for the specific python that you are targeting. I do not know anything about WinPython, but for a normal python installation this means doing something like this:
C:\Python34\python configure.py
As a first step, before attempting to actually compile anything, it would be advisable to take at look at all the configuration options that are available, like this:
C:\Python34\python configure.py --help
(There's also the Installing PyQt5 section in the PyQt Docs).
This will tell you, for instance, that the simplest way to specify the Qt installation you are targeting would be something like this:
C:\Python34\python configure.py --qmake C:\Qt\5.4\mingw491_32\bin\qmake
EDIT:
Sorry, that last part is wrong: the --qmake option isn't available on Windows, so you have to add the directory containing the qmake executable to your PATH. This can be done with the following command:
set PATH=%PATH%;C:\Qt\5.4\mingw491_32\bin

grunt assemble error _config.yml file not generated?

I'm working to try to install the boilerplate-bootstrap example in a effort to learn/play around with assemble. The example fails for me after I try to run grunt saying to please run bower install before continuing. Looking in the Gruntfile.js, I can see that it is looking for vendor/bootstrap/_config.yml. Seems like I'm doing something pretty basic wrong here. the example I'm referring to is listed here:
https://github.com/assemble/boilerplate-bootstrap
Let me know if you have any suggestions at all for me - thanks
Just follow the prompt and run bower install bootstrap. All will make sense afterwards. The _config.yml file is in the root of the Bootstrap project, but you won't find it unless Bootstrap is downloaded with Bower first.

Error on travis-ci build "No Rakefile found"

One github repo builds fine on travis, while another with almost exactly the same .travis.yaml file does not build, and gives the error
rake aborted!
No Rakefile found (looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb)
I have seen some discussions about travis yaml files not dealing with tabs correctly, etc. but I have checked there are no tabs, only whitespaces.
I have noticed that the config line on the travis dashboard has an entry for the repo that builds correctly
while the one that doesn't build is missing that line
However, they have the same yaml file more or less, so I don't understand why it doesn't work the same way.
The yaml for the repo that builds
And the one that doesn't build (some comments are removed, but that doesn't make a difference, I checked):
I think you should rename the file to .travis.yml.
Sometimes I see it used in a right way but here it is misspelled. That is why it is not executed.

Resources