Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dartanalyzer -h - could not startup process #12

Closed
lucasderksen opened this issue Mar 24, 2020 · 14 comments
Closed

dartanalyzer -h - could not startup process #12

lucasderksen opened this issue Mar 24, 2020 · 14 comments
Labels
bug Something isn't working fixed on develop

Comments

@lucasderksen
Copy link

Im trying to run the sonar-scanner command but get an error telling me it could not startup dartanalyzer -h even though it works directly when i use dartananalyzer -h in cmd line.

INFO: ------------------------------------------------------------------------ INFO: EXECUTION FAILURE INFO: ------------------------------------------------------------------------ INFO: Total time: 5.754s INFO: Final Memory: 36M/130M INFO: ------------------------------------------------------------------------ ERROR: Error during SonarQube Scanner execution org.buildobjects.process.StartupException: Could not startup process 'dartanalyzer -h'. at org.buildobjects.process.Proc.<init>(Proc.java:91) at org.buildobjects.process.ProcBuilder.run(ProcBuilder.java:205) at fr.insideapp.sonarqube.dart.lang.issues.dartanalyzer.DartAnalyzerSensor.verifyCommand(DartAnalyzerSensor.java:129) at fr.insideapp.sonarqube.dart.lang.issues.dartanalyzer.DartAnalyzerSensor.execute(DartAnalyzerSensor.java:84) at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:48) at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:85) at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:59) at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:77) at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:59) at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:82) at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136) at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122) at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:386) at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:382) at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:351) at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136) at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122) at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:141) at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136) at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122) at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72) at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:66) at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60) at com.sun.proxy.$Proxy0.execute(Unknown Source) at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189) at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138) at org.sonarsource.scanner.cli.Main.execute(Main.java:112) at org.sonarsource.scanner.cli.Main.execute(Main.java:75) at org.sonarsource.scanner.cli.Main.main(Main.java:61) Caused by: java.io.IOException: Cannot run program "dartanalyzer": CreateProcess error=2, Het systeem kan het opgegeven bestand niet vinden at java.base/java.lang.ProcessBuilder.start(Unknown Source) at java.base/java.lang.ProcessBuilder.start(Unknown Source) at java.base/java.lang.Runtime.exec(Unknown Source) at org.buildobjects.process.Proc.<init>(Proc.java:77) ... 33 more Caused by: java.io.IOException: CreateProcess error=2, Het systeem kan het opgegeven bestand niet vinden at java.base/java.lang.ProcessImpl.create(Native Method) at java.base/java.lang.ProcessImpl.<init>(Unknown Source) at java.base/java.lang.ProcessImpl.start(Unknown Source) ... 37 more

when running the command directly in the same directory it does work. see code below.

`D:\Development\Flutter\KlankenBak_Repo\KlankenBak\klankenbak>dartanalyzer -h
Usage: dartanalyzer [options...]

--dart-sdk                  The path to the Dart SDK.
--options                   Path to an analysis options file.
--package-root              The path to a package root directory (deprecated). This option cannot be used with --packages.
--[no-]declaration-casts    Disable declaration casts in strong mode (https://goo.gl/cTLz40)
                            This option is now ignored and will be removed in a future release.

--[no-]implicit-casts       Disable implicit casts in strong mode (https://goo.gl/cTLz40).
--no-implicit-dynamic       Disable implicit dynamic (https://goo.gl/m0UgXD).
--packages                  The path to the package resolution configuration file, which supplies a mapping of package names
                            to paths. This option cannot be used with --package-root.

--[no-]lints                Show lint results.
--format                    Specifies the format in which errors are displayed; the only currently allowed value is 'machine'.
--version                   Print the analyzer version.
--enable-experiment         Enable one or more experimental features. If multiple features are being added, they should be comma separated.
--no-hints                  Do not show hint results.
--fatal-infos               Treat infos as fatal.
--fatal-warnings            Treat non-type warnings as fatal.

-h, --help Display this help message. Add --verbose to show hidden options.
-v, --verbose Verbose output.

Run "dartanalyzer -h -v" for verbose help output, including less commonly used options.
For more information, see https://www.dartlang.org/tools/analyzer.`

@Cutux
Copy link

Cutux commented Mar 24, 2020

Hello, that happened to me on Windows, somehow it doesn't work properly..

And because I was just testing on my machine I just deployed it into a container with Linux and it worked properly.

Not sure if this is a bug on Windows.

@lucasderksen
Copy link
Author

hmm alright, thanks for the reply, might try it in a container aswell.
it could be a windows specific bug indeed.

@skindud
Copy link

skindud commented Mar 31, 2020

I have the same error with docker sonarqube:7.6-community:

ERROR: Error during SonarQube Scanner execution
org.buildobjects.process.StartupException: Could not startup process 'dartanalyzer -h'.
	at org.buildobjects.process.Proc.<init>(Proc.java:91)
	at org.buildobjects.process.ProcBuilder.run(ProcBuilder.java:205)

@skindud
Copy link

skindud commented Apr 3, 2020

The error can be fixed by Flutter/Dart installation.

@mszeptun
Copy link

mszeptun commented Apr 6, 2020

I have the same error, already install Flutter and Dart. Waiting for some solution as I need it for my Master Thesis

@lahann
Copy link

lahann commented Apr 15, 2020

The error can be fixed by Flutter/Dart installation.

Hey @skindud , can you explain how exactly the installation of Flutter/Dart fixed it for you?

I got the same error. The following command works in cmd but not when I run sonar-scanner

C:\tmp> dartanalyzer -h
Usage: dartanalyzer [options...] <directory or list of files>

@skindud
Copy link

skindud commented Apr 15, 2020

The error can be fixed by Flutter/Dart installation.

Hey @skindud , can you explain how exactly the installation of Flutter/Dart fixed it for you?

I got the same error. The following command works in cmd but not when I run sonar-scanner

C:\tmp> dartanalyzer -h
Usage: dartanalyzer [options...] <directory or list of files>

The root cause of the error that there is not dartanalyzer (or not PATH to it) in the system.
I have just run "flutter pub get" (in this case flutter download and install dartanalyzer add path to the program to PATH environment variables)

cd $GIT_FOLDER && flutter pub get cd ~ && export PATH="$PATH:###pwd###/flutter/bin/cache/dart-sdk/bin" cd $GIT_FOLDER && dartanalyzer lib/

@bikotoru
Copy link

Has anyone been able to fix it in windows?
install flutter, install dart, but it still doesn't work.

PATH = C:\Program Files (x86)\Common Files\Oracle\Java\javapath;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0;C:\ProgramData\chocolatey\bin;C:\flutter\bin;C:\flutter\bin\cache\dart-sdk\bin;C:\Program Files\Git\cmd

image

and if from the server run dartanalyzer -h

image

@lifehalo
Copy link

lifehalo commented May 4, 2020

In the file DartAnalyzerSensor.java,

Change the following line.

//private static final String ANALYZER_COMMAND = "dartanalyzer";
private static final String ANALYZER_COMMAND = "dartanalyzer.bat";

Use Maven to re-compile and generate jar file.

@Omniscience619
Copy link

Encountered the same error in while implementing this in a SonarQube Docker.

The problem lies in the fact that an efficient installation of Dart and Flutter is difficult in a container, except for creating volumes and binding them to the container.

I have all the files in my container, all paths assigned, and even then, SonarQube says that it could not execute dartanalyzer -h

Request you to look into it, it's a similar issue as that of OP.

@rzld
Copy link

rzld commented May 13, 2020

The error can be fixed by Flutter/Dart installation.

Hey @skindud , can you explain how exactly the installation of Flutter/Dart fixed it for you?
I got the same error. The following command works in cmd but not when I run sonar-scanner

C:\tmp> dartanalyzer -h
Usage: dartanalyzer [options...] <directory or list of files>

The root cause of the error that there is not dartanalyzer (or not PATH to it) in the system.
I have just run "flutter pub get" (in this case flutter download and install dartanalyzer add path to the program to PATH environment variables)

cd $GIT_FOLDER && flutter pub get cd ~ && export PATH="$PATH:###pwd###/flutter/bin/cache/dart-sdk/bin" cd $GIT_FOLDER && dartanalyzer lib/

This fixes the problem for me. I just added the path to my ".../flutter/bin/cache/dart-sdk/bin" and then it works.

@phantrungphat
Copy link

I'm facing this error, but result of command "dartanalyzer -h" in the same directory and it don't work.
I tried to fix dartanalyzer, but it was hopeless. It show me that "dartanalyzer: command not found".
my errors:
ERROR: Error during SonarQube Scanner execution
ERROR: Could not startup process 'dartanalyzer -h'.
ERROR: Caused by: Cannot run program "dartanalyzer": CreateProcess error=2, The system cannot find the file specified
ERROR: Caused by: CreateProcess error=2, The system cannot find the file specified
ERROR:
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.

Anybody help me!!!

@zippy1978
Copy link
Contributor

Hi all,
The error is related to the fact that dartanalyzer command cannot be found on the path.
However, I do not have any Windows box around me.

@lifehalo solution could be the right one.
Did someone had the chance to test it ?
If so, I will push the fix n the next release.

@zippy1978 zippy1978 added bug Something isn't working fixed on develop labels Aug 9, 2020
@zippy1978
Copy link
Contributor

Hi,
This issue was fixed in 0.3.0.
I close it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed on develop
Projects
None yet
Development

No branches or pull requests