I'm trying to create and apply a simple patch to fix a bug with gradle.
I copy the file (/usr/bin/gradle) to my working directory, then make the change. I then create the patch:
diff -u /usr/bin/gradle gradle > gradle.patch
Then I attempt to apply it:
sudo patch < gradle.patch
Reversed (or previously applied) patch detected! Assume -R? [n]
If I proceed anyway, it fails. I have tried generating the patch with the files reversed, and in this case it applies "successfully," but does nothing.
The generated patch looks like this:
--- /usr/bin/gradle 2013-09-09 16:47:58.000000000 -0400
+++ gradle 2015-10-13 11:39:36.005269565 -0400
@@ -67,7 +67,8 @@
CLASSPATH=$APP_HOME/lib/gradle-launcher-1.4.jar
-export JAVA_HOME=/usr/lib/jvm/default-java
+# commenting out as per (https://stackoverflow.com/a/22309017)
+# export JAVA_HOME=/usr/lib/jvm/default-java
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
I have tried editing the file paths at the top of the patch to both be /usr/bin/gradle, however this doesn't help.
I have also tried passing -p0, in which case it give:
Ignoring potentially dangerous file name /usr/bin/gradle
can't find file to patch at input line 3
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|--- /usr/bin/gradle 2013-09-09 16:47:58.000000000 -0400
|+++ /usr/bin/gradle 2015-10-13 11:39:36.005269565 -0400
--------------------------
File to patch: /usr/bin/gradle
File /usr/bin/gradle is not a regular file -- refusing to patch
1 out of 1 hunk ignored -- saving rejects to file /usr/bin/gradle.rej
When I specify the file in this case, it still fails.
This seems like a simple task, what am I doing wrong?