sbaudoin/sonar-shellcheck

Error while GitLab scans shell scripts

Closed this issue · 4 comments

Hi,

I am getting the following error "ERROR: Error executing command: Cannot run program "shellcheck": error=2, No such file or directory. ERROR: Is the command installed and in the path?" on GitLab pipeline when scanning shell scripts.

This plugin was installed on the server where sonarqube is hosted and I added the /usr/bin/shellcheck PATH to .bashrc as well as sourced it to sync up. I also restarted the server after all the steps mentioned.

Versions:
sonar-shellcheck - 2.4.0
sonar version - 8.6.0.39681-0 on Debian 10 (AMI provided by bitnami)
shellcheck - 0.5.0

I would like to see the static code analysis of the shell scripts in the specified project. Can you provide suggestions/thoughts on what might be incorrect in the setup?

Regards,
Sumukha

Hello @sbaudoin,

Can you please take a look into this issue?

Thanks,
SKP

Hello,

Have you tried configuring the absolute path to shellcheck in the plugin settings? /usr/bin may not be in the default PATH, and changing the path in .bashrc won't help because Java does not run commands in interactive shells. So you have only a few options:

  • Add /usr/bin to the default system PATH (somewhere in a file under /etc but I can't tell which one)
  • Set the absolute path /usr/bin/shellcheck to the plugin settings
  • Link /usr/bin/shellcheck in a directory that is part of the default system PATH

I'd preferably go for option 2.

@Sumukha15 Is this issue still relevant? Also make sure shellcheck is installed on the machine that runs the scanner (e.g. if the scanner is executed inside a Docker container, shellcheck must be installed inside the container).

@sbaudoin, I am closing this issue for now and will try the fix that you have provided.

Thanks.