sdk
sdk copied to clipboard
Analyzer error on bad paths in package config is unactionable
When passing a package config with --packages and running dart analyze, there is no actionable feedback if any of the paths in that config are broken. Other dart commands like run produce more actionable feedback.
Repro steps
Create an app with a broken config:
dart create testapp- `cd testapp
- `mkdir .dart_tool/nested
mv .dart_tool/package_config.json .dart_tool/nested/(we now have a package_config with is bad, as it uses relative paths)
Analyze:
$ dart --packages=.dart_tool/nested/package_config.json analyze .
Analyzing .... 1.5s
error • bin/testapp.dart:1:8 • Target of URI doesn't exist: 'package:testapp/testapp.dart'. Try creating the file referenced by the URI, or Try
using a URI for a file that does exist. • uri_does_not_exist
This does give any feedback mentioning the file it's trying to locate, so it's not really actionable. Compare to run:
$ dart --packages=.dart_tool/nested/package_config.json run bin/testapp.dart
bin/testapp.dart:1:8: Error: Error when reading '.dart_tool/lib/testapp.dart': No such file or directory
import 'package:testapp/testapp.dart' as testapp;
^