MovingBlocks / Terasology

Terasology - open source voxel world
http://terasology.org
Apache License 2.0
3.64k stars 1.32k forks source link

Workspace Setup Issues on Windows #5256

Open jdrueckert opened 1 week ago

jdrueckert commented 1 week ago

General Info

Terasology Version: latest develop (state of June 17) Operating System: Windows Java Version: 17

What you were trying to do

Follow https://terasology.org/Terasology/#/Contributor-Quick-Start for setting up a Terasology workspace on Windows. At step 5, use Intellij

What actually happened

After preparing the modules on commandline using groovyw, I attempted to run the TerasologyPC run config in Intellij. On building I received an error stating that there was no protobuf package as referenced in engine/src/main/java/org/terasology/engine/network/Server.java.

Next, I tried starting from commandline using gradlew game. This worked and both, the splash screen and the Terasology UI showed up.

Afterwards, I tried starting Terasology from Intellij again using the TerasologyPC run config. This time no protobuf error, but instead the following initialization failure on starting up Terasology:

21:57:06.998 [main] ERROR o.t.engine.core.TerasologyEngine - Failed to initialise Terasology
java.lang.NullPointerException: null
    at java.base/java.io.Reader.<init>(Reader.java:168)
    at java.base/java.io.InputStreamReader.<init>(InputStreamReader.java:76)
    at org.terasology.engine.config.Config.loadDefaultToJson(Config.java:158)
    at org.terasology.engine.config.Config.load(Config.java:140)
    at org.terasology.engine.core.subsystem.common.ConfigurationSubsystem.preInitialise(ConfigurationSubsystem.java:51)
    at org.terasology.engine.core.TerasologyEngine.preInitSubsystems(TerasologyEngine.java:292)
    at org.terasology.engine.core.TerasologyEngine.initialize(TerasologyEngine.java:224)

How to reproduce

  1. Setup a fresh Terasology workspace on Windows see Contributor Quick Start Steps 1-4 (there's no more prompt by the way)
  2. Start Terasology from Intellij using the TerasologyPC run config
  3. Observe the protobuf error
  4. Start Terasology from commandline via gradlew game
  5. Observe Terasology starting properly
  6. Start Terasology from Intellij using the TerasologyPC run config again
  7. See initialization error
skaldarnar commented 1 week ago

I'm able to start Terasology on Windows with a minimal development setup using just IntelliJ (not following the developer quickstart guide, though). I used IntelliJ to clone the repo, install Temurin 17.0.11 as my SDK, import the Gradle project and then run gradlew jar and gradlew game through the UI.

Initializing the workspace with more modules is a bit more cumbersome that way, as there's basically no Java "installed" on my machine, so just typing ./groovyw ... in the integrated terminal is not doing much 😔

I'm not entirely sure about protobuf but I'm wondering whether gradlew extractNatives plays a role here...

skaldarnar commented 1 week ago

Oh, and I'm hitting a different error when trying to launch via TerasologyPC...

C:\Users\tobia\.jdks\temurin-17.0.11\bin\java.exe -Xms256m -Xmx1536m "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2024.1.1\lib\idea_rt.jar=55085:C:\Program Files\JetBrains\IntelliJ IDEA 2024.1.1\bin" -Dfile.encoding=UTF-8 -classpath C:\Users\tobia\AppData\Local\Temp\classpath1962329546.jar org.terasology.engine.Terasology --homedir=. --no-crash-report
Fehler: Hauptklasse org.terasology.engine.Terasology konnte nicht gefunden oder geladen werden
Ursache: java.lang.ClassNotFoundException: org.terasology.engine.Terasology

Process finished with exit code 1

(Cannot reproduce this after cloning the repo again, though...)

skaldarnar commented 1 week ago

Possibly related: https://youtrack.jetbrains.com/issue/IDEA-209418/Gradle-generated-Protobuf-Java-sources-are-not-detected-added-as-module-dependencies-for-Gradle-project-korlin-dsl

It looks like the TerasologyPC task is not generating the protobuf files properly. The folder engine/build/generated/source/proto/main/java just stays empty. When running gradlew jar, the respective Java files are generated into that folder.

Regarding the second error (missing default.cfg): When running the game via Gradle, the default.cfg is picked up from jar:file:/F:/code/movingblocks/terasology/engine/build/libs/engine-5.4.0-SNAPSHOT.jar!/default.cfg. When running via TerasologyPC, no such file is found in the classpath...

skaldarnar commented 1 week ago

I'm wondering whether we wnat to keep the IntelliJ run configurations, or whether we can switch to completely using the Gradle-based tasks instead 🤔 grafik That way, starting via IntelliJ and starting via command line would the same, probably eliminiating a whole class of errors...