Closed alexiswilliams closed 2 years ago
Hi @alexiswilliams - thanks for reporting this issue. Based on the information you've provided, my guess is that the java home value is set as a relative path instead of an absolute path.
In ~/.sfdx-scanner/Config.json
file, there should be javaHome
property.
If it exists:
/usr/local/Cellar/openjdk@11/11.0.12/libexec/openjdk.jdk/Contents/Home
according to your post)If it doesn't exist:
~/.sfdx-scanner/Config.json
JAVA_HOME
env variable (echo $JAVA_HOME
). If the value is set to a path, check if the path exists. In general, relative paths such as ../libexec/openjdk.jdk/Contents/Home
could lead to flakiness and an absolute path such as /usr/local/Cellar/openjdk@11/11.0.12/libexec/openjdk.jdk/Contents/Home
would work at all times. Rerunning sfdx scanner should regenerate the config file with javaHome
property.
Please let us know if these steps fixed the issue.
@rmohan20 thank you for a quick response. Your answer solved the problem. Thank you as well for the guidance which is very much appreciated.
Describe the bug run any command such as sfdx scanner:run --format xml --target ./force-app/main/default message returned Error: ENOENT: no such file or directory, lstat '../libexec/openjdk.jdk/Contents/Home/bin/java' at Object.lstatSync (node:fs:1516:3) at findLinkedFile (/Users/alexiswilliams/.local/share/sfdx/node_modules/find-java-home/dist/index.js:257:13) at findLinkedFile (/Users/alexiswilliams/.local/share/sfdx/node_modules/find-java-home/dist/index.js:259:12) at /Users/alexiswilliams/.local/share/sfdx/node_modules/find-java-home/dist/index.js:155:24 at /Users/alexiswilliams/.local/share/sfdx/node_modules/find-java-home/node_modules/which/which.js:52:18 at FSReqCallback.oncomplete (node:fs:199:5) { errno: -2, syscall: 'lstat', code: 'ENOENT', path: '../libexec/openjdk.jdk/Contents/Home/bin/java' } Error: ENOENT: no such file or directory, lstat '../libexec/openjdk.jdk/Contents/Home/bin/java' at Object.lstatSync (node:fs:1516:3) at findLinkedFile (/Users/alexiswilliams/.local/share/sfdx/node_modules/find-java-home/dist/index.js:257:13) at findLinkedFile (/Users/alexiswilliams/.local/share/sfdx/node_modules/find-java-home/dist/index.js:259:12) at /Users/alexiswilliams/.local/share/sfdx/node_modules/find-java-home/dist/index.js:155:24 at /Users/alexiswilliams/.local/share/sfdx/node_modules/find-java-home/node_modules/which/which.js:52:18 at FSReqCallback.oncomplete (node:fs:199:5) { errno: -2, syscall: 'lstat', code: 'ENOENT', path: '../libexec/openjdk.jdk/Contents/Home/bin/java' } To Reproduce Use brew to install openjdk11 Install sfdx using sfdx plugins:install @salesforce/sfdx-scanner % ls /usr/local/Cellar/openjdk@11/11.0.12/libexec/openjdk.jdk/Contents/Home/bin/java /usr/local/Cellar/openjdk@11/11.0.12/libexec/openjdk.jdk/Contents/Home/bin/java --version openjdk 11.0.12 2021-07-20 OpenJDK Runtime Environment Homebrew (build 11.0.12+0) OpenJDK 64-Bit Server VM Homebrew (build 11.0.12+0, mixed mode) Expected behavior Commands run without lstat error message.
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Additional context Add any other context about the problem here.
"Workaround": Have you found any ways to sidestep the problem? Running PMD directly with shell script instead of scanner plugin
"Urgency": How severe is this problem? "Business stopping" vs "Not business-stopping". Customer demo at risk for sfdx plugin using functions to demonstrate using custom rules without having to use PMD