FabricMC / fabric-loom

Gradle build system plugin used to automate the setup of a minecraft mod development environment.
MIT License
226 stars 194 forks source link

Gson Error when Reloading Project (1.20.4 Loom 1.5.2) #1020

Closed thomasglasser closed 6 months ago

thomasglasser commented 6 months ago

When refreshing my project recently, it fails with this log: https://paste.gg/p/anonymous/45026e85e656461fbfd6f09ef27127bf This started happening seemingly out of the blue and I've deleted and refreshed and cleared caches but I can't find the cause

modmuss50 commented 6 months ago

Do you have any other Gradle plugins? It seems to be using GSON 2.9.1, but loom depends on 2.10.1. Running with --info might provide some details on where this is coming from.

thomasglasser commented 6 months ago

This is what --info says about gson (com.google.gson.Gson) with version (null) was loaded from (/C:/Users/tjgla/.gradle/caches/modules-2/files-2.1/com.google.code.gson/gson/2.9.1/2cc2131b98ebfb04e2b2c7dfb84431f4045096b/gson-2.9.1.jar)

modmuss50 commented 6 months ago

Is this a project with multiple sub projects? I have a feeling this is the age old issue of Gradle not pulling in the correct versions of libraries.

If so all your plugin versions must be defined in the root build.gradle file with apply false

See: https://docs.gradle.org/current/userguide/plugins.html#sec:subprojects_plugins_dsl and https://github.com/FabricMC/fabric-loader/blob/master/build.gradle#L15

thomasglasser commented 6 months ago

Doesnt have any subprojects. I tried putting id 'gson' version '2.10.+' apply false but it can't find it

thomasglasser commented 6 months ago

Downgrading to 1.4.6 fixes it so it's a 1.5 or above change

jpenilla commented 6 months ago

May be related to https://github.com/gradle/foojay-toolchains/pull/52

modmuss50 commented 6 months ago

May be related to gradle/foojay-toolchains#52

Yes, quite possibly. @thomasglasser can you provide a project where this doesnt work. I dont think you mentioned if you had any other Gradle plugins or not?

zml2008 commented 6 months ago

I'm running into the same issue as well in https://github.com/KyoriPowered/adventure-platform-fabric/pull/125 -- jmp has a workaround in his foojay PR, I ended up doing this as an alternate workaround. Hopefully our Gradle friends will be able to put out a release soon to resolve this issue for now? The whole classloader hierarchy thing is very unfortunate.

modmuss50 commented 6 months ago

Im going to close this as I dont think there is anything I can do to help with this, im also not going to let it block the 1.5 stable release.

thomasglasser commented 6 months ago

I think this may be caused by having deps that don't use loom 1.5

thomasglasser commented 6 months ago

Because my project with no deps works fine. The workaround seems to have fixed it