Error when running: node -v. Is Node.js available?

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?

1 Like

Hi @UltraMax.

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:

❯ ls -la sonar-scanner-5.0.1.3006-linux/jre/lib/
total 180536
drwxr-xr-x@ 48 davi.koscianski-vidal  staff      1536 Aug  4  2023 .
drwxr-xr-x@  8 davi.koscianski-vidal  staff       256 Aug  4  2023 ..
-rw-r--r--@  1 davi.koscianski-vidal  staff     71366 Apr 18  2023 classlist
-rwxr-xr-x@  1 davi.koscianski-vidal  staff     16584 Apr 18  2023 jexec
drwxr-xr-x@  4 davi.koscianski-vidal  staff       128 Aug  4  2023 jfr
-rw-r--r--@  1 davi.koscianski-vidal  staff    110511 Apr 18  2023 jrt-fs.jar
-rwxr-xr-x@  1 davi.koscianski-vidal  staff     21904 Apr 18  2023 jspawnhelper
[...]

How did you get the scanner under your /opt directory?

You also mentioned the following:

Can you paste your $PATH variable and the output of which git and which node?
From where did you download the scanner and how did you unpack it?