From 0c4f2711d62c9b53c080abe0978096f8b23c0b0d Mon Sep 17 00:00:00 2001 From: Mads Ager Date: Mon, 14 Mar 2022 12:59:39 +0100 Subject: [PATCH] Avoid reading /tmp/build.txt in standalone compiler invocations. ^KT-51627 Fixed kotlinc will currently read /tmp/build.txt in an attempt to determine an IDEA version number for IDEA plugin compatibility checking. If that file exists and does not match the expected format kotlinc will fail. Since standalone kotlinc is not IDEA, this change explicitly sets the system property for the build number to a fallback value. That avoids reading /tmp/build.txt. closes https://github.com/JetBrains/kotlin/pull/4763 --- .../src/org/jetbrains/kotlin/cli/jvm/compiler/compat.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/compat.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/compat.kt index 1b8de704c72..002d3abd2d8 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/compat.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/compat.kt @@ -10,6 +10,8 @@ import com.intellij.openapi.diagnostic.Logger object IdeaStandaloneExecutionSetup { private val LOG: Logger = Logger.getInstance(IdeaStandaloneExecutionSetup::class.java) + // Copy-pasted from com.intellij.openapi.util.BuildNumber#FALLBACK_VERSION + private const val FALLBACK_IDEA_BUILD_NUMBER = "999.SNAPSHOT" fun doSetup() { checkInHeadlessMode() @@ -20,7 +22,10 @@ object IdeaStandaloneExecutionSetup { System.getProperties().setProperty("ide.hide.excluded.files", "false") System.getProperties().setProperty("ast.loading.filter", "false") System.getProperties().setProperty("idea.ignore.disabled.plugins", "true") - System.getProperties().setProperty("idea.home.path", System.getProperty("java.io.tmpdir")) + // Setting the build number explicitly avoids the command-line compiler + // reading /tmp/build.txt in an attempt to get a build number from there. + // See intellij platform PluginManagerCore.getBuildNumber. + System.getProperties().setProperty("idea.plugins.compatible.build", FALLBACK_IDEA_BUILD_NUMBER) } private fun checkInHeadlessMode() { @@ -33,4 +38,4 @@ object IdeaStandaloneExecutionSetup { } // We safe this function to minimize the patch for release branches -fun setupIdeaStandaloneExecution() = IdeaStandaloneExecutionSetup.doSetup() \ No newline at end of file +fun setupIdeaStandaloneExecution() = IdeaStandaloneExecutionSetup.doSetup()