Skip to content
This repository was archived by the owner on Jul 16, 2023. It is now read-only.
This repository was archived by the owner on Jul 16, 2023. It is now read-only.

[BUG] Compiling CLI to exe on Windows #385

Closed
@roman-petrov

Description

@roman-petrov

Today we discussed CLI analysis performance with @dkrutskikh and decided to try to compile CLI tool to exe on Windows (using dart compile exe) as a possible workaround.

Compilation works fine, but when I try to launch analysis with created executable like metrics.exe C:\Projects\dart-code-metrics i get runtime exceptions, here is the output:

[exception: FileSystemException(path=C:\Projects\lib\_internal\sdk_library_metadata\lib\libraries.dart; message=Cannot open file)][stackTrace: #0      _PhysicalFile.readAsStringSync (package:analyzer/file_system/physical_file_system.dart:184)
#1      FolderBasedDartSdk.initialLibraryMap (package:analyzer/src/dart/sdk/sdk.dart:473)
#2      new FolderBasedDartSdk (package:analyzer/src/dart/sdk/sdk.dart:371)
#3      ContextBuilder.findSdk.<anonymous closure> (package:analyzer/src/context/builder.dart:198)
#4      _HashMap.putIfAbsent (dart:collection-patch/collection_patch.dart:140)
#5      DartSdkManager.getSdk (package:analyzer/src/generated/sdk.dart:95)
#6      ContextBuilder.findSdk (package:analyzer/src/context/builder.dart:197)
#7      ContextBuilder.createSourceFactoryFromWorkspace (package:analyzer/src/context/builder.dart:167)
#8      ContextBuilder.buildDriver (package:analyzer/src/context/builder.dart:110)
#9      ContextBuilderImpl.createContext (package:analyzer/src/dart/analysis/context_builder.dart:91)
#10     new AnalysisContextCollectionImpl (package:analyzer/src/dart/analysis/analysis_context_collection.dart:63)
#11     LintAnalyzer.runCliAnalysis (package:dart_code_metrics/src/analyzers/lint_analyzer/lint_analyzer.dart:75)
#12     CliRunner.runAnalysis (package:dart_code_metrics/src/cli/cli_runner.dart:21)
<asynchronous suspension>
#13     main (file:///c:/projects/dart-code-metrics/bin/metrics.dart:4)
<asynchronous suspension>
]
[exception: FileSystemException(path=C:\Projects\lib\_internal\libraries.dart; message=Cannot open file)][stackTrace: #0      _PhysicalFile.readAsStringSync (package:analyzer/file_system/physical_file_system.dart:184)
#1      FolderBasedDartSdk.initialLibraryMap (package:analyzer/src/dart/sdk/sdk.dart:473)
#2      new FolderBasedDartSdk (package:analyzer/src/dart/sdk/sdk.dart:371)
#3      ContextBuilder.findSdk.<anonymous closure> (package:analyzer/src/context/builder.dart:198)
#4      _HashMap.putIfAbsent (dart:collection-patch/collection_patch.dart:140)
#5      DartSdkManager.getSdk (package:analyzer/src/generated/sdk.dart:95)
#6      ContextBuilder.findSdk (package:analyzer/src/context/builder.dart:197)
#7      ContextBuilder.createSourceFactoryFromWorkspace (package:analyzer/src/context/builder.dart:167)
#8      ContextBuilder.buildDriver (package:analyzer/src/context/builder.dart:110)
#9      ContextBuilderImpl.createContext (package:analyzer/src/dart/analysis/context_builder.dart:91)
#10     new AnalysisContextCollectionImpl (package:analyzer/src/dart/analysis/analysis_context_collection.dart:63)
#11     LintAnalyzer.runCliAnalysis (package:dart_code_metrics/src/analyzers/lint_analyzer/lint_analyzer.dart:75)
#12     CliRunner.runAnalysis (package:dart_code_metrics/src/cli/cli_runner.dart:21)
<asynchronous suspension>
#13     main (file:///c:/projects/dart-code-metrics/bin/metrics.dart:4)
<asynchronous suspension>
]

As you can see, the source of these exceptions is not dart_code_metrics itself, they are coming from analyzer package.

Not sure if anything can be done here from our side, it seems we will need changes from Dart SDK team.

I created this issue because @dkrutskikh suggested me to do so, please feel free to just close it if you like :)

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions