I use Sonar-scanner-cli-5.0.1.3006-linux.zip in LInux
I have downloaded and started it successfully but I have errors running any executables in sonar in analysis
ERROR: Error when running: ‘/home/dashboard/.nvm/versions/node/v18.18.2/bin/node -v’. Is Node.js available during analysis?
org.sonar.plugins.javascript.nodejs.NodeCommandException: Error when running: ‘/home/dashboard/.nvm/versions/node/v18.18.2/bin/node -v’. Is Node.js available during analysis?
…
Caused by: java.io.IOException: Cannot run program “/home/dashboard/.nvm/versions/node/v18.18.2/bin/node”: error=13, Permission denied
and
WARN: Cannot run program “/usr/bin/git” (in directory “/usr/bin”): error=13, Permission denied
But when I try run this command under the same user in linux I get
git --version
git version 2.31.1
node -v
v16.14.2
I wonder what is wrong here? Why node and git are normally run under user but can’t be run if I run sonar-scanner by the same user?
Today I also tried to run sonar-scanner under root and still have these issues
when I tried the running process I saw
root 1388050 1385745 99 17:24 pts/2 00:00:04 /opt/sonar-scanner/jre/bin/java -Djava.awt.headless=true -classpath /opt/sonar-scanner/lib/sonar-scanner-cli-5.0.1.3006.jar -Dscanner.home=/opt/sonar-scanner -Dproject.home=/root/git/api-core org.sonarsource.scanner.cli.Main
Can this be an issue related to some java permissions? if yes how should sonar-scanner be set up to avoid such issues?
Well, this is insane
The root cause was that /opt/sonar-scanner/jre/lib/jspawnhelper did not have executable permissions
After I have set it to 755 all problems had gone
I do not know if it’s ok that for linux version download has only zip files that do not preserve file attributes and I needed to compare all files with the server where all worked fine
Can we ask developers to create tar.gz archive that saves all attributes while unpacking?
I just downloaded the scanner from the link in our documentation, unpacked it with unzip sonar-scanner-cli-5.0.1.3006-linux.zip and this is the result:
@UltraMax, for information, while preparing my new laptop, I faced the exact same issue and also had to set jre/lib/jspawnhelper as executable. Sonar Scanner is installed in a custom directory, but I believe this is not the issue. I think that, depending on how Sonar Scanner was installed, it could exhibit the issues.
In my case, it was a simple copy of the sonar-scanner directory from my previous laptop to the new one which, obviously, didn’t propagate the permissions. Granted, this is not a usual situation.
Still, it would probably be better if the error message was reflecting the actual issue (jre/lib/jspawnhelper is not executable).