diff --git a/sonar-plugin/bridge/src/main/java/org/sonar/plugins/javascript/bridge/EmbeddedNode.java b/sonar-plugin/bridge/src/main/java/org/sonar/plugins/javascript/bridge/EmbeddedNode.java index 0a03e79df30..c2742c94ee6 100644 --- a/sonar-plugin/bridge/src/main/java/org/sonar/plugins/javascript/bridge/EmbeddedNode.java +++ b/sonar-plugin/bridge/src/main/java/org/sonar/plugins/javascript/bridge/EmbeddedNode.java @@ -201,7 +201,15 @@ public void deploy() throws IOException { LOG.debug("Deployed node version {}", detected); isAvailable = true; } catch (Exception e) { - LOG.warn("Embedded Node.js failed to deploy. Will fallback to host Node.js.", e); + LOG.warn(""" + Embedded Node.js failed to deploy in {}. + You can change the location by setting the option `sonar.userHome` or the environment variable `SONAR_USER_HOME`. + Otherwise, it will default to {}. + Will fallback to host Node.js.""", + Environment.defaultSonarUserHome(), + deployLocation, + e + ); } } diff --git a/sonar-plugin/bridge/src/main/java/org/sonar/plugins/javascript/bridge/Environment.java b/sonar-plugin/bridge/src/main/java/org/sonar/plugins/javascript/bridge/Environment.java index 2fba07213f1..f73f1edf996 100644 --- a/sonar-plugin/bridge/src/main/java/org/sonar/plugins/javascript/bridge/Environment.java +++ b/sonar-plugin/bridge/src/main/java/org/sonar/plugins/javascript/bridge/Environment.java @@ -49,7 +49,7 @@ public Path getSonarUserHome() { .of( configuration.get("sonar.userHome").orElse(null), System.getenv("SONAR_USER_HOME"), - System.getProperty("user.home") + File.separator + ".sonar" + defaultSonarUserHome() ) .filter(Objects::nonNull) .findFirst() @@ -57,6 +57,10 @@ public Path getSonarUserHome() { .get(); } + public static String defaultSonarUserHome() { + return System.getProperty("user.home") + File.separator + ".sonar"; + } + public String getOsName() { return System.getProperty("os.name"); } diff --git a/sonar-plugin/bridge/src/test/java/org/sonar/plugins/javascript/bridge/EmbeddedNodeTest.java b/sonar-plugin/bridge/src/test/java/org/sonar/plugins/javascript/bridge/EmbeddedNodeTest.java index bff2d72bbc4..6d819555f17 100644 --- a/sonar-plugin/bridge/src/test/java/org/sonar/plugins/javascript/bridge/EmbeddedNodeTest.java +++ b/sonar-plugin/bridge/src/test/java/org/sonar/plugins/javascript/bridge/EmbeddedNodeTest.java @@ -179,7 +179,9 @@ void should_fail_gracefully() throws Exception { en.deploy(); assertThat(logTester.logs()) .anyMatch(l -> - l.startsWith("Embedded Node.js failed to deploy. Will fallback to host Node.js") + l.startsWith("Embedded Node.js failed to deploy in ") && + l.contains("You can change the location by setting the option `sonar.userHome` or the environment variable `SONAR_USER_HOME`.") && + l.endsWith("Will fallback to host Node.js.") ); }