nimmis / docker-spigot

A docker container with spigot, builds spigot.jar on first start
175 stars 82 forks source link

BuildTools fails (You must run this jar through bash (msysgit)) #63

Closed BlvckBytes closed 1 year ago

BlvckBytes commented 1 year ago

After a long debugging session I finally found out that BuildTools failed, which is why I got the following failed startup:

crond                            RUNNING   pid 288, uptime 0:00:04
spigot                           BACKOFF   Exited too quickly (process log may have details)
syslog-ng                        RUNNING   pid 292, uptime 0:00:04

I saw that BuildTools didn't produce a jar, so I tried running it manually. After this unhelpful print of You must run this jar through bash (msysgit), I decided to download it's source and print the exception it catches just before printing that line:

root@ab60c1941b21:/build-mc# java -jar BuildTools.jar
Loading BuildTools version: git-BuildTools-unknown-unknown (#-1)
Java Version: Java 17
Current Path: /build-mc/.
This command is not for general use and should only be run as the result of a call to
ProcessBuilder.start() or Runtime.exec() in a java application
java.io.IOException: Cannot run program "sh" (in directory "."): error=0, Failed to exec spawn helper: pid: 731, exit value: 1
    at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1143)
    at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1073)
    at org.spigotmc.builder.Builder.runProcess0(Builder.java:984)
    at org.spigotmc.builder.Builder.runProcess(Builder.java:924)
    at org.spigotmc.builder.Builder.main(Builder.java:197)
    at org.spigotmc.builder.Bootstrap.main(Bootstrap.java:27)
Caused by: java.io.IOException: error=0, Failed to exec spawn helper: pid: 731, exit value: 1
    at java.base/java.lang.ProcessImpl.forkAndExec(Native Method)
    at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:314)
    at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:244)
    at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1110)
    ... 5 more
You must run this jar through bash (msysgit)

This seems to be an OpenJDK issue on Linux for which the java option -Djdk.lang.Process.launchMechanism=vfork provides a workaround. See: https://stackoverflow.com/a/61325264

My local scenario also seems to not execute BuildTools successfully with 1G of memory, as the process just stalls after some time. By increasing memory, I at least get to yet another error:

Exception in thread "main" org.eclipse.jgit.errors.RepositoryNotFoundException: repository not found: /build-mc/Bukkit
    at org.eclipse.jgit.lib.BaseRepositoryBuilder.build(BaseRepositoryBuilder.java:627)
    at org.eclipse.jgit.api.Git.open(Git.java:93)
    at org.eclipse.jgit.api.Git.open(Git.java:73)
    at org.spigotmc.builder.Builder.main(Builder.java:371)
    at org.spigotmc.builder.Bootstrap.main(Bootstrap.java:27

Has anybody else encountered these issues too? Seems like I'm really out of luck on this one. But to be fair, BuildTools is just really badly written software, so I was not at all surprised about encountering stupid issues like these.

nimmis commented 1 year ago

What are you start parameter and which environment did you run it in. Tested docker run -d -e EULA=true --name mc nimmis/spigot on Ubuntu 20.04/Docker 20.10.23 and got

*** Running /etc/my_runonce/90_autorestart...
*** Run files in /etc/my_runalways/
*** Running /etc/my_runalways/00_minecraft_owner...
*** Running /etc/my_runalways/10_set_mc_version...
*** Running /etc/my_runalways/50_do_build_spigot...
checking latest
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  148k  100  148k    0     0   318k      0 --:--:-- --:--:-- --:--:--  318k
Setting version to latest
set java version to 17
Building spigot version (latest) jar file, be patient
--2023-01-22 15:47:03--  https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar
Resolving hub.spigotmc.org (hub.spigotmc.org)... 104.27.195.95, 104.27.196.95, 2606:4700:21::681b:c45f, ...
Connecting to hub.spigotmc.org (hub.spigotmc.org)|104.27.195.95|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 4565952 (4.4M) [application/java-archive]
Saving to: ‘/build-mc/BuildTools.jar’
.........
Success! Everything completed successfully. Copying final .jar files now.
Copying spigot-1.19.3-R0.1-SNAPSHOT-bootstrap.jar to /build-mc/./spigot-1.19.3.jar
  - Saved as ./spigot-1.19.3.jar
Successful build of spigot version latest
Setting latest as current spigot version
*** Running /etc/my_runalways/85_fix_startsh...
start.sh missing, creating link for /minecraft/start.sh
*** Running /etc/my_runalways/90_eula...
*** Booting supervisor daemon...
*** Supervisor started as PID 695
*** Started processes via Supervisor......
crond                            RUNNING   pid 697, uptime 0:00:04
spigot                           RUNNING   pid 698, uptime 0:00:04
syslog-ng                        RUNNING   pid 699, uptime 0:00:04

to be on the safe side I tested the same settings on a mac and it worked there too.

BlvckBytes commented 1 year ago

Thanks so much for taking the time out of your day in order to test the behaviour on your machines, @nimmis! I'm very sorry to tell you, but the issue was entirely due to my own ignorance. I completely forgot that I have to adjust the JDK download URL to point at the ARM release, as I'm running on a M1 MBP. I completely forgot about this, as Rosetta usually makes it so that Java "just works". Of course, there's no rosetta in a Docker-Container... duh!

I now edited

https://github.com/adoptium/temurin${JAVA_VERSION_MAJOR}-binaries/releases/download/jdk-${JAVA_VERSION_MAJOR}.${JAVA_VERSION_MINOR}%2B${JAVA_VERSION_UPDATE}/OpenJDK${JAVA_VERSION_MAJOR}U-jdk_x64_linux_${JAVA_OPT}_${JAVA_VERSION_MAJOR}.${JAVA_VERSION_MINOR}_${JAVA_VERSION_UPDATE}.tar.gz

to point at jdk_aarch64_linux instead of jdk_x64_linux. Everything works out ever since. The initial error messages I got really threw me for a loop, as they did not at all point me in that direction.