{"record":{"id":"56a91a09ffafe5d6","repo":"gradle/gradle","slug":"unable-to-determine-scala-version","errorCode":null,"errorMessage":"Unable to determine scala version","messagePattern":"Unable to determine scala version","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"platforms/jvm/scala-compiler-worker/src/main/java/org/gradle/api/internal/tasks/scala/ZincScalaCompilerFactory.java","lineNumber":252,"sourceCode":"        });\n    }\n\n    private static File findFile(String prefix, ClassPath classpath) {\n        for (File f : classpath.getAsFiles()) {\n            if (f.getName().startsWith(prefix)) {\n                return f;\n            }\n        }\n        throw new IllegalStateException(String.format(\"Cannot find any files starting with %s in %s\", prefix, classpath.getAsFiles()));\n    }\n\n    private static String getScalaVersion(ClassLoader scalaClassLoader) {\n        try {\n            Properties props = new Properties();\n            props.load(scalaClassLoader.getResourceAsStream(\"compiler.properties\"));\n            return props.getProperty(\"version.number\");\n        } catch (IOException e) {\n            throw new IllegalStateException(\"Unable to determine scala version\");\n        }\n    }\n\n\n}\n","sourceCodeStart":234,"sourceCodeEnd":258,"githubUrl":"https://github.com/gradle/gradle/blob/534f27719b66953f95cc907aae7f2c1b12f5482d/platforms/jvm/scala-compiler-worker/src/main/java/org/gradle/api/internal/tasks/scala/ZincScalaCompilerFactory.java#L234-L258","documentation":"ZincScalaCompilerFactory.getScalaVersion opens compiler.properties from the classloader holding the Scala compiler and reads the version.number property to select the correct compiler bridge and Zinc setup. Any IOException while loading the stream is rethrown as IllegalStateException('Unable to determine scala version'), meaning the Scala compiler jar on the classpath does not carry a readable compiler.properties.","triggerScenarios":"The scala-compiler jar on scalaClasspath is corrupted (truncated download), was repackaged/stripped without compiler.properties, or is a non-standard home-grown Scala build whose distribution omits the properties file.","commonSituations":"Locally published or shaded scala-compiler artifacts missing metadata; broken caches after an interrupted download; a proxy serving HTML error pages as jars; using a patched/forked Scala distribution.","solutions":["Check the caused-by IOException and inspect the scala-compiler jar on the classpath (jar tf scala-compiler-*.jar | grep compiler.properties)","Purge the cached artifact: ./gradlew build --refresh-dependencies (or delete it under ~/.gradle/caches/modules-2) so a clean copy is downloaded","Replace stripped/forked scala-compiler with the official org.scala-lang:scala-compiler artifact of the same version","If you must publish a custom Scala distribution, ensure compiler.properties with version.number is preserved in the jar"],"exampleFix":"// before: locally patched distribution without compiler.properties\nimplementation 'com.example:scala-compiler-patched:2.13.14'\n// after: official distribution keeps compiler.properties intact\nimplementation 'org.scala-lang:scala-compiler:2.13.14'\nimplementation 'org.scala-lang:scala-library:2.13.14'","handlingStrategy":"validation","validationCode":"// verify compiler.properties exists and is readable inside every scala-compiler jar\nconfigurations.matching { it.name.toLowerCase().contains('scala') }.all { cfg ->\n    cfg.files.findAll { it.name.startsWith('scala-compiler') }.each { jar ->\n        assert new java.util.zip.ZipFile(jar).getEntry('compiler.properties') != null : \\\n            \"${jar} lacks compiler.properties\"\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use official org.scala-lang artifacts instead of repackaged Scala distributions","When publishing custom Scala jars, keep META-INF/compiler.properties with version.number intact","After network hiccups, build with --refresh-dependencies to replace possibly truncated jars","Cache poisoning check: delete suspect artifacts under ~/.gradle/caches/modules-2 and re-resolve"],"tags":["scala","gradle","zinc","corrupt-jar","version-detection"],"backgroundTag":"missing-resource-file","analyzedSha":"534f27719b66953f95cc907aae7f2c1b12f5482d","analyzedAt":"2026-08-22T08:09:12.375Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}