[BUILDTOOLS-1] applyPatches.sh is the incorrect file encoding Created: 28/Nov/14  Updated: 19/Feb/19  Resolved: 28/Nov/14

Status: Resolved
Project: BuildTools
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Robert Coelho Assignee: GunfighterJ
Resolution: Fixed Votes: 1
Labels: BuildTools
Environment:

Ubuntu 14.10 Elementary OS



 Description   

The file "applyPatches.sh" is encoded using DOS encoding. When running the file using bash on unix systems due to this, you receive the following error:

$ bash applyPatches.sh
applyPatches.sh: line 2: $'\r': command not found
Rebuilding Forked projects.... 
applyPatches.sh: line 6: $'\r': command not found
applyPatches.sh: line 7: syntax error near unexpected token `$'{\r''
'pplyPatches.sh: line 7: `function applyPatch {

Using dos2unix resolves this easily:
http://linuxcommand.org/man_pages/dos2unix1.html



 Comments   
Comment by Alex R [ 19/Feb/19 ]

I get an identical error to comments above me, the git command did not help.

I'm running Fedora Linux 29.

dos2unix does not seem to help, I'm guessing applyPatches.sh gets redownloaded.

Comment by Logan Saso [ 08/Aug/17 ]

Same Issue:

applyPatches.sh: line 2: $'\r': command not found
Rebuilding Forked projects....
applyPatches.sh: line 6: $'\r': command not found
applyPatches.sh: line 7: syntax error near unexpected token `$'{\r''
applyPatches.sh: line 7: `function applyPatch {
'
Error compiling Spigot. Please check the wiki for FAQs.
If this does not resolve your issue then please pastebin the entire BuildTools.log.txt file when seeking support.
java.lang.RuntimeException: Error running command, return status !=0: [bash, applyPatches.sh]
at org.spigotmc.builder.Builder.runProcess(Builder.java:561)
at org.spigotmc.builder.Builder.main(Builder.java:443)

Ran

git config --global --unset core.autocrlf

It didn't work. Windows 10 (64-bit)

Comment by Jakub Mareda [ 06/Jan/17 ]

This is not fixed. I just downloaded recent build tools and I got this error:

applyPatches.sh: line 2: $'\r': command not found
Rebuilding Forked projects....
applyPatches.sh: line 6: $'\r': command not found
applyPatches.sh: line 7: syntax error near unexpected token `$'{\r''
applyPatches.sh: line 7: `function applyPatch {
'
Error compiling Spigot. Please check the wiki for FAQs.
If this does not resolve your issue then please pastebin the entire BuildTools.log.txt file when seeking support.
java.lang.RuntimeException: Error running command, return status !=0: [bash, applyPatches.sh]
        at org.spigotmc.builder.Builder.runProcess(Builder.java:552)
        at org.spigotmc.builder.Builder.main(Builder.java:434)

I did use this command, didn't change a thing:


git config --global --unset core.autocrlf

{/code}

I also tried to change the file new lines to \n manually in advanced text editor.

Comment by GunfighterJ [ 28/Nov/14 ]

git config --global --unset core.autocrlf
will fix the issue

Comment by GunfighterJ [ 28/Nov/14 ]

Good to hear it's working.

As for the spigot issue, that is being looked in to and being resolved.

Comment by Robert Coelho [ 28/Nov/14 ]

Changed the git setting you referenced, removed my working directory and attempted to retry. It seems this issue has been fixed and the encoding of the file is correct.

$ sha1sum applyPatches.sh
f1c084bee04aaf02b479310729376b3c10ad4c07  applyPatches.sh

It seems a recent commit made the actual build process break however:

Applying: Check for manually prefixed commands or commands that don't need a prefix for calling vanilla commands with command blocks
fatal: sha1 information is lacking or useless (src/main/java/net/minecraft/server/CommandBlockListenerAbstract.java).
Repository lacks necessary blobs to fall back on 3-way merge.
Cannot fall back to three-way merge.
Patch failed at 0098 Check for manually prefixed commands or commands that don't need a prefix for calling vanilla commands with command blocks
The copy of the patch that failed is found in:
   ./BuildTools/Spigot/Spigot-Server/.git/rebase-apply/patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
  Something did not apply cleanly to Spigot-Server.
  Please review above details and finish the apply then
  save the changes with rebuildPatches.sh

But this issue itself seems fixed.

Comment by GunfighterJ [ 28/Nov/14 ]

Sorry, not set to true, unset it.
git config --global --unset core.autocrlf

Comment by GunfighterJ [ 28/Nov/14 ]

Make sure you have core.autocrlf set to true in for your git config

Comment by Robert Coelho [ 28/Nov/14 ]
coelho@coelho:~$ git clone https://hub.spigotmc.org/stash/scm/spigot/spigot.git
Cloning into 'spigot'...
remote: Counting objects: 10203, done.
remote: Compressing objects: 100% (1764/1764), done.
remote: Total 10203 (delta 8435), reused 10183 (delta 8424)
Receiving objects: 100% (10203/10203), 2.24 MiB | 876.00 KiB/s, done.
Resolving deltas: 100% (8435/8435), done.
Checking connectivity... done.
coelho@coelho:~$ cd spigot
coelho@coelho:~/spigot$ ls
applyPatches.sh  CraftBukkit-Patches  README.md          upstreamMerge.sh
Bukkit-Patches   pom.xml              rebuildPatches.sh
coelho@coelho:~/spigot$ sha1sum applyPatches.sh
57dbfa12c0b2558c004e034e7b6f773f324b9a52  applyPatches.sh

It seems to not be the same checksum for me.

Comment by GunfighterJ [ 28/Nov/14 ]

A fresh clone gives me the correct applyPatches.sh
http://i.gunfighterj.com/YmZhNTU

Comment by Robert Coelho [ 28/Nov/14 ]

I'm referring to applyPatches.sh, as stated in the title.

https://hub.spigotmc.org/stash/projects/SPIGOT/repos/spigot/browse/applyPatches.sh

Comment by GunfighterJ [ 28/Nov/14 ]

Which repo?
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse ?
The makePatches.sh in that directory is the one that should be used.

Comment by Robert Coelho [ 28/Nov/14 ]

https://coelho.ninja/files/applyPatches.sh.dos2unix
sha1sum: f1c084bee04aaf02b479310729376b3c10ad4c07

https://coelho.ninja/files/applyPatches.sh.orig
sha1sum: 57dbfa12c0b2558c004e034e7b6f773f324b9a52

Different encodings. First works on my system, second does not. Second is what is in the repo.

Comment by GunfighterJ [ 28/Nov/14 ]

Can you link me the exact makePatches.sh script you are using on stash?

Comment by GunfighterJ [ 28/Nov/14 ]

I am unable to reproduce with a fresh clone of craftbukkit.

Generated at Sun Sep 07 20:26:11 UTC 2025 using Jira 10.3.9#10030009-sha1:eff8913ed2270ee44ab422c3609af4c4f36536d0.