diff --git a/main/src/main/scala/sbt/Main.scala b/main/src/main/scala/sbt/Main.scala index 4db35148f..8f3ee4584 100644 --- a/main/src/main/scala/sbt/Main.scala +++ b/main/src/main/scala/sbt/Main.scala @@ -61,6 +61,7 @@ private[sbt] object xMain: private[sbt] def run(configuration: xsbti.AppConfiguration): xsbti.MainResult = boundary { try { + if (!sys.props.contains("jna.nosys")) sys.props.put("jna.nosys", "true") import BasicCommandStrings.{ JavaClient, DashDashClient, DashDashServer, runEarly } import BasicCommands.early import BuiltinCommands.defaults @@ -265,7 +266,7 @@ object StandardMain { preCommands: Seq[String] ): State = { // This is to workaround https://github.com/sbt/io/issues/110 - sys.props.put("jna.nosys", "true") + if (!sys.props.contains("jna.nosys")) sys.props.put("jna.nosys", "true") import BasicCommandStrings.{ DashDashDetachStdio, DashDashServer, isEarlyCommand } val userCommands = diff --git a/project/Scripted.scala b/project/Scripted.scala index de692d210..9bd2f3649 100644 --- a/project/Scripted.scala +++ b/project/Scripted.scala @@ -25,7 +25,7 @@ trait ScriptedKeys { object Scripted { // This is to workaround https://github.com/sbt/io/issues/110 - sys.props.put("jna.nosys", "true") + if (!sys.props.contains("jna.nosys")) sys.props.put("jna.nosys", "true") val RepoOverrideTest = config("repoOverrideTest") extend Compile diff --git a/sbt-app/src/test/scala/sbt/RunFromSourceMain.scala b/sbt-app/src/test/scala/sbt/RunFromSourceMain.scala index 8919cee30..d0f8e7ca9 100644 --- a/sbt-app/src/test/scala/sbt/RunFromSourceMain.scala +++ b/sbt-app/src/test/scala/sbt/RunFromSourceMain.scala @@ -56,7 +56,7 @@ object RunFromSourceMain { s"Must specify working directory, scala version and sbt version and classpath as the first three arguments" ) case Array(wd, scalaVersion, sbtVersion, classpath, args*) => - System.setProperty("jna.nosys", "true") + if (System.getProperty("jna.nosys") == null) System.setProperty("jna.nosys", "true") if (args.exists(_.startsWith("<"))) System.setProperty("sbt.io.virtual", "false") val context = LoggerContext() try run(file(wd), scalaVersion, sbtVersion, classpath, args, context)