JetBrains / intellij-platform-gradle-plugin

Gradle plugin for building plugins for IntelliJ-based IDEs
https://plugins.jetbrains.com/docs/intellij/gradle-prerequisites.html
Apache License 2.0
1.43k stars 271 forks source link

IntelliJ Ultimate 211.6693.111 cannot be run (`Resource not found: /idea/nullApplicationInfo.xml`) #1348

Closed bric3 closed 1 year ago

bric3 commented 1 year ago

Describe the bug Gradle-intellij-plugin pass "null" value to the system property idea.platform.prefix, for IntelliJ Ultimate 211.6693.111 (platform type IU).

This prevents to run the IDE or to execute buildSearchableOptions.

I cannot debug the Gradle task even with Enable Gradle script debugging

image

but in ApplicationNamesInfo.loadData I see the returned property is "null", rather than the default one "".

image

This creates the following resource /idea/nullApplicationInfo.xml path, but this doesn't exists. If the idea.platform.prefix property was unset, or set to "", then loadData would find the file /idea/ApplicationInfo.xml in resources.jar.

image
./gradlew buildPlugin --info ``` > Task :buildSearchableOptions Build cache key for task ':buildSearchableOptions' is 16dee8005bdc2e76ad05c662e125b305 Task ':buildSearchableOptions' is not up-to-date because: Value of input property 'ideDir' has changed for task ':buildSearchableOptions' [gradle-intellij-plugin :] Build feature is enabled: org.jetbrains.intellij.buildFeature.paidPluginSearchableOptionsWarning [gradle-intellij-plugin :buildSearchableOptions] Looking for platform prefix [gradle-intellij-plugin :buildSearchableOptions] Using idea.platform.prefix=null The configuration :detachedConfiguration7 is both resolvable and consumable. This is considered a legacy configuration and it will eventually only be possible to be one of these. The configuration :detachedConfiguration7 is both consumable and declarable. This combination is incorrect, only one of these flags should be set. The configuration :detachedConfiguration7 is both resolvable and consumable. This is considered a legacy configuration and it will eventually only be possible to be one of these. The configuration :detachedConfiguration7 is both consumable and declarable. This combination is incorrect, only one of these flags should be set. [gradle-intellij-plugin :] Resolved JVM Runtime directory: /Users/brice.dutheil/.gradle/caches/modules-2/files-2.1/com.jetbrains/jbre/jbr_jcef-11_0_10-osx-aarch64-b1341.35/extracted/jbr/Contents/Home/bin/java The configuration :detachedConfiguration8 is both resolvable and consumable. This is considered a legacy configuration and it will eventually only be possible to be one of these. The configuration :detachedConfiguration8 is both consumable and declarable. This combination is incorrect, only one of these flags should be set. The configuration :detachedConfiguration8 is both resolvable and consumable. This is considered a legacy configuration and it will eventually only be possible to be one of these. The configuration :detachedConfiguration8 is both consumable and declarable. This combination is incorrect, only one of these flags should be set. [gradle-intellij-plugin :] Resolved JVM Runtime directory: /Users/brice.dutheil/.gradle/caches/modules-2/files-2.1/com.jetbrains/jbre/jbr_jcef-11_0_10-osx-aarch64-b1341.35/extracted/jbr/Contents/Home/bin/java Starting process 'command '/Users/brice.dutheil/.gradle/caches/modules-2/files-2.1/com.jetbrains/jbre/jbr_jcef-11_0_10-osx-aarch64-b1341.35/extracted/jbr/Contents/Home/bin/java''. Working directory: /Users/brice.dutheil/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/ideaIU/211.6693.111/fb73193bad7ac7619a8bfac40db2cb035e38bd13/ideaIU-211.6693.111/bin Command: /Users/brice.dutheil/.gradle/caches/modules-2/files-2.1/com.jetbrains/jbre/jbr_jcef-11_0_10-osx-aarch64-b1341.35/extracted/jbr/Contents/Home/bin/java -Dapple.awt.fileDialogForDirectories=true -Dapple.laf.useScreenMenuBar=true -Didea.auto.reload.plugins=true -Didea.classpath.index.enabled=false -Didea.config.path=/Users/brice.dutheil/opensource/idea-conventional-commit/build/idea-sandbox/config -Didea.is.internal=true -Didea.log.path=/Users/brice.dutheil/opensource/idea-conventional-commit/build/idea-sandbox/system/log -Didea.platform.prefix=null -Didea.plugin.in.sandbox.mode=true -Didea.plugins.path=/Users/brice.dutheil/opensource/idea-conventional-commit/build/idea-sandbox/plugins -Didea.required.plugins.id=com.github.lppedd.idea-conventional-commit -Didea.smooth.progress=false -Didea.system.path=/Users/brice.dutheil/opensource/idea-conventional-commit/build/idea-sandbox/system -Didea.vendor.name=JetBrains -Djdk.attach.allowAttachSelf=true -Djdk.http.auth.tunneling.disabledSchemes="" -Djdk.module.illegalAccess.silent=true -Dkotlinx.coroutines.debug=off -Dsun.io.useCanonCaches=false -XX:ReservedCodeCacheSize=512m -XX:+UseG1GC -XX:SoftRefLRUPolicyMSPerMB=50 -XX:CICompilerCount=2 -XX:+HeapDumpOnOutOfMemoryError -XX:-OmitStackTraceInFastThrow -XX:ErrorFile=$USER_HOME/java_error_in_idea_%p.log -XX:HeapDumpPath=$USER_HOME/java_error_in_idea.hprof --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.ref=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.nio=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED --add-opens=java.base/java.time=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.base/jdk.internal.vm=ALL-UNNAMED --add-opens=java.base/sun.nio.ch=ALL-UNNAMED --add-opens=java.base/sun.nio.fs=ALL-UNNAMED --add-opens=java.base/sun.security.ssl=ALL-UNNAMED --add-opens=java.base/sun.security.util=ALL-UNNAMED --add-opens=java.desktop/java.awt=ALL-UNNAMED --add-opens=java.desktop/java.awt.dnd.peer=ALL-UNNAMED --add-opens=java.desktop/java.awt.event=ALL-UNNAMED --add-opens=java.desktop/java.awt.image=ALL-UNNAMED --add-opens=java.desktop/java.awt.peer=ALL-UNNAMED --add-opens=java.desktop/java.awt.font=ALL-UNNAMED --add-opens=java.desktop/javax.swing=ALL-UNNAMED --add-opens=java.desktop/javax.swing.plaf.basic=ALL-UNNAMED --add-opens=java.desktop/javax.swing.text.html=ALL-UNNAMED --add-opens=java.desktop/sun.awt.datatransfer=ALL-UNNAMED --add-opens=java.desktop/sun.awt.image=ALL-UNNAMED --add-opens=java.desktop/sun.awt=ALL-UNNAMED --add-opens=java.desktop/sun.font=ALL-UNNAMED --add-opens=java.desktop/sun.java2d=ALL-UNNAMED --add-opens=java.desktop/sun.swing=ALL-UNNAMED --add-opens=jdk.attach/sun.tools.attach=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-opens=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED --add-opens=jdk.jdi/com.sun.tools.jdi=ALL-UNNAMED --add-opens=java.desktop/com.apple.laf=ALL-UNNAMED --add-opens=java.desktop/com.apple.eawt.event=ALL-UNNAMED --add-opens=java.desktop/com.apple.eawt=ALL-UNNAMED --add-opens=java.desktop/sun.lwawt.macosx=ALL-UNNAMED --add-opens=java.desktop/sun.lwawt=ALL-UNNAMED -Xms128m -Xmx750m -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant -ea -cp /Users/brice.dutheil/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/ideaIU/211.6693.111/fb73193bad7ac7619a8bfac40db2cb035e38bd13/ideaIU-211.6693.111/lib/bootstrap.jar:/Users/brice.dutheil/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/ideaIU/211.6693.111/fb73193bad7ac7619a8bfac40db2cb035e38bd13/ideaIU-211.6693.111/lib/util.jar:/Users/brice.dutheil/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/ideaIU/211.6693.111/fb73193bad7ac7619a8bfac40db2cb035e38bd13/ideaIU-211.6693.111/lib/jdom.jar:/Users/brice.dutheil/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/ideaIU/211.6693.111/fb73193bad7ac7619a8bfac40db2cb035e38bd13/ideaIU-211.6693.111/lib/log4j.jar:/Users/brice.dutheil/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/ideaIU/211.6693.111/fb73193bad7ac7619a8bfac40db2cb035e38bd13/ideaIU-211.6693.111/lib/jna.jar com.intellij.idea.Main traverseUI /Users/brice.dutheil/opensource/idea-conventional-commit/build/searchableOptions true Successfully started process 'command '/Users/brice.dutheil/.gradle/caches/modules-2/files-2.1/com.jetbrains/jbre/jbr_jcef-11_0_10-osx-aarch64-b1341.35/extracted/jbr/Contents/Home/bin/java'' 2023-03-20 15:50:11,984 [ 86] ERROR - oncurrency.BoundedTaskExecutor - Resource not found: /idea/nullApplicationInfo.xml java.lang.RuntimeException: Resource not found: /idea/nullApplicationInfo.xml at com.intellij.openapi.application.ApplicationNamesInfo.loadData(ApplicationNamesInfo.java:30) at com.intellij.openapi.application.ApplicationNamesInfo.initAndGetRawData(ApplicationNamesInfo.java:45) at com.intellij.openapi.application.impl.ApplicationInfoImpl.getShadowInstance(ApplicationInfoImpl.java:478) at com.intellij.idea.StartupUtil.lambda$prepareApp$4(StartupUtil.java:233) at com.intellij.util.concurrency.BoundedTaskExecutor.doRun(BoundedTaskExecutor.java:216) at com.intellij.util.concurrency.BoundedTaskExecutor.access$200(BoundedTaskExecutor.java:27) at com.intellij.util.concurrency.BoundedTaskExecutor$1.execute(BoundedTaskExecutor.java:195) at com.intellij.util.concurrency.BoundedTaskExecutor$1.run(BoundedTaskExecutor.java:187) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:668) at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:665) at java.base/java.security.AccessController.doPrivileged(Native Method) at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:665) at java.base/java.lang.Thread.run(Thread.java:834) 2023-03-20 15:50:13,381 [ 1483] ERROR - llij.ide.plugins.PluginManager - Resource not found: /idea/nullApplicationInfo.xml java.lang.RuntimeException: Resource not found: /idea/nullApplicationInfo.xml at com.intellij.openapi.application.ApplicationNamesInfo.loadData(ApplicationNamesInfo.java:30) at com.intellij.openapi.application.ApplicationNamesInfo.initAndGetRawData(ApplicationNamesInfo.java:45) at com.intellij.openapi.application.impl.ApplicationInfoImpl.getShadowInstance(ApplicationInfoImpl.java:478) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at com.intellij.idea.MainImpl.a(MainImpl.java:110) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at com.intellij.idea.MainImpl.start(MainImpl.java:93) at com.intellij.idea.StartupUtil.startApp(StartupUtil.java:310) at com.intellij.idea.StartupUtil.prepareApp(StartupUtil.java:250) at com.intellij.ide.plugins.MainRunner.lambda$start$1(MainRunner.java:41) at java.base/java.lang.Thread.run(Thread.java:834) Start Failed Internal error. Please refer to https://jb.gg/ide/critical-startup-errors ```

To Reproduce For now I have reproduced it while working on https://github.com/lppedd/idea-conventional-commit/issues/116

I believe the only trigger appear to be the product type being IU and using an old enough platform version like 211.6693.111.

Expected behavior No problem running IU.

Environment:

bric3 commented 1 year ago

Note the workaround when the platform is IU is to force the value to an empty String.

  runIde {
+   systemProperty("idea.platform.prefix", "")
  }

Actually I managed to debug the Gradle task I had to remove Debug forked task in the same session.

So the issue is that getValue returns "null", thus the ifNull guard is not executed

            OperatingSystem.current().isMacOsX && infoPlist != null -> infoPlist
                ?.getDictionary("JVMOptions")
                ?.getDictionary("Properties")
                ?.getValue("idea.platform.prefix") // <---- this returns "null"
                .ifNull { error(context, "Cannot find prefix in $infoPlist") }

Indeed on

fun NSDictionary.getValue(key: String) = this[key].toString()

the .toString() doc says it will return "null"

/**
 * Returns a string representation of the object. Can be called with a null receiver, in which case
 * it returns the string "null".
 */
bric3 commented 1 year ago

Actually on 2022.1 the gradle-intellij-plugin is doing the same, but ApplicationNamesInfo.loadData is significantly different than before so it doesn't fail. The code actually returns earlier and ignore the value of the idea.platform.prefix property.

image
hsz commented 1 year ago

Thanks for the investigation, Brice! Fixed with e4e7338

bric3 commented 1 year ago

you're welcome