Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JS-70 More descriptive log when extracting node fails #4834

Merged
merged 2 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,18 @@ 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()
.map(Path::of)
.get();
}

public static String defaultSonarUserHome() {
return System.getProperty("user.home") + File.separator + ".sonar";
}

public String getOsName() {
return System.getProperty("os.name");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
);
}

Expand Down