Index: pkg/analyzer_cli/lib/src/build_mode.dart |
diff --git a/pkg/analyzer_cli/lib/src/build_mode.dart b/pkg/analyzer_cli/lib/src/build_mode.dart |
index 511c6c099ddb23d18eae2b513c724a92eaeb2252..7bc499946f76bb4ad8218c94797e11e572644919 100644 |
--- a/pkg/analyzer_cli/lib/src/build_mode.dart |
+++ b/pkg/analyzer_cli/lib/src/build_mode.dart |
@@ -348,7 +348,6 @@ class WorkerLoop { |
* Performs analysis with given [options]. |
*/ |
void analyze(CommandLineOptions options) { |
- options.dartSdkPath ??= dartSdkPath; |
new BuildMode(options, new AnalysisStats()).analyze(); |
} |
@@ -361,9 +360,16 @@ class WorkerLoop { |
if (request == null) { |
return true; |
} |
+ // Add in the dart-sdk argument if `dartSdkPath` is not null, otherwise it |
+ // will try to find the currently installed sdk. |
+ var arguments = new List.from(request.arguments); |
+ if (dartSdkPath != null && |
+ !arguments.any((arg) => arg.startsWith('--dart-sdk'))) { |
+ arguments.add('--dart-sdk=$dartSdkPath'); |
+ } |
// Prepare options. |
CommandLineOptions options = |
- CommandLineOptions.parse(request.arguments, (String msg) { |
+ CommandLineOptions.parse(arguments, (String msg) { |
throw new ArgumentError(msg); |
}); |
// Analyze and respond. |