sdk icon indicating copy to clipboard operation
sdk copied to clipboard

Analyzer error on bad paths in package config is unactionable

Open mit-mit opened this issue 3 years ago • 0 comments

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:

  1. dart create testapp
  2. `cd testapp
  3. `mkdir .dart_tool/nested
  4. 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;
       ^       

mit-mit avatar Jul 28 '22 16:07 mit-mit