Dotnet-sonarscanner 5.2.1 /usr/bin/env: ‘sh’: No such file or directory

I don’t know if this is related to the same issue but dotnet-sonarscanner version 5.2.1 fails the command “dotnet-sonarscanner end” when run in docker and fails to send the report to SonarCube.
Error is : “Calling the SonarScanner CLI…
/usr/bin/env: ‘sh’: No such file or directory
The SonarScanner did not complete successfully”
Version 5.2.0 works fine.

ok, in that case there is some other problem in version 5.2.1 maybe @Andrei_Epure you can investigate. Workaround at the moment is install version 5.2.0

Hi @MPujol

What is your docker base image ?
How are you downloading the scanner ?

Thanks.

Hi @mickaelcaro
base image is mcr.microsoft.com/dotnet/core/sdk:3.1
sonarscanner is installed with command “dotnet tool install --global dotnet-sonarscanner”

br

Thanks @MPujol

Did a quick test on my side, i didn’t reproduced that issue.

Can you issue the following command inside your docker context and tell me the output please :

cd ~/.dotnet/tools/.store/dotnet-sonarscanner/5.2.1/dotnet-sonarscanner/5.2.1/tools/netcoreapp3.0/any/sonar-scanner-4.6.1.2450/bin
file sonar-scanner

hi @mickaelcaro the output is “file: not found”

Have you reverted to version 5.2.0 already ? This file exists somewhere otherwise you wouldn’t have this error message (maybe not at this exact place).

Yes, at the moment we have to explicitly install 5.2.0. (dotnet tool install --global dotnet-sonarscanner --version 5.2.0)
No changes in the project(s) was done. with version 5.2.1 (latest) sonarscanner fails.

Hi @MPujol

How does look your dockerfile ? How are you installing the dotnet command ?

We defitenly changed the header of the shell executable from 5.2.0 to 5.2.1, but as i said, did a small test with the same image as your, and didn’t reproduce that. So it’s more likely some change in the Line endings of the file, or any other extra setup made.

HTH,

Mickaël

do we have a resolution for this issue, I see similar issue with version 5.7.2.

00:30:01.949 Writing processing summary to /source/.sonarqube/out/ProjectInfo.log
Calling the SonarScanner CLI…
Executing file /root/.dotnet/tools/.store/dotnet-sonarscanner/5.7.2/dotnet-sonarscanner/5.7.2/tools/net5.0/any/sonar-scanner-4.7.0.2747/bin/sonar-scanner
Args: -Dsonar.scanAllFiles=true -Dproject.settings=/source/.sonarqube/out/sonar-project.properties --from=ScannerMSBuild/5.7.2 --debug
Working directory: /source
Timeout (ms):-1
Process id: 214
/usr/bin/env: ‘sh’: No such file or directory
Process returned exit code 127
The SonarScanner did not complete successfully
00:30:02.011 Post-processing failed. Exit code: 1
[Pipeline] }
WARN: Unable to locate ‘report-task.txt’ in the workspace. Did the SonarScanner succeed?

The docker command is

docker run --rm -v $PWD:/source mcr.microsoft.com/dotnet/sdk:6.0 bash -c “cd source && ls -l /usr/bin/env && dotnet tool install --global dotnet-sonarscanner && export PATH=$PATH:/root/.dotnet/tools && dotnet-sonarscanner begin /d:sonar.verbose=true /k:$projectKey /n:$projectName /v:${BUILD_NUMBER} /d:sonar.login=${SONAR_AUTH_TOKEN} /d:sonar.host.url=${SONAR_HOST_URL} && dotnet restore Rubicon.BackOffice.ComplianceApi.csproj && dotnet build -c Release && dotnet-sonarscanner end /d:sonar.login=${SONAR_AUTH_TOKEN}”

1 Like