Skip to content

dartanalyzer can't resolve package: URIs unless it's in the dir of the project #24116

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

Closed
sethladd opened this issue Aug 18, 2015 · 5 comments
Closed
Labels
legacy-area-analyzer Use area-devexp instead. P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@sethladd
Copy link
Contributor

Consider this case:

  • create a dummy project (via stagehand package-simple)
  • pub get
  • cd to your home directory
  • run dartanalyzer path/to/dummy/project/bin/main.dart

Expected: analysis to work

Actual:

~ $ dartanalyzer ~/tmp/testpkg/bin/main.dart 
Analyzing [/Users/sethladd/tmp/testpkg/bin/main.dart]...
[error] Target of URI does not exist: 'package:testpkg/testpkg.dart' (/Users/sethladd/tmp/testpkg/bin/main.dart, line 4, col 8)
[warning] Undefined name 'testpkg' (/Users/sethladd/tmp/testpkg/bin/main.dart, line 4, col 42)
[warning] Undefined name 'testpkg' (/Users/sethladd/tmp/testpkg/bin/main.dart, line 8, col 25)
1 error and 2 warnings found.

If I cd into my dummy project, I can analyze:

~ $ cd tmp/testpkg/
~/tmp/testpkg $ dartanalyzer bin/main.dart 
Analyzing [bin/main.dart]...
No issues found

FWIW the VM runs the code from an arbitrary directory

~ $ dart ~/tmp/testpkg/bin/main.dart 
Hello world: 42!
@sethladd sethladd added Type-Defect legacy-area-analyzer Use area-devexp instead. labels Aug 18, 2015
@sethladd
Copy link
Contributor Author

cc @pq

@pq
Copy link
Member

pq commented Aug 19, 2015

After chatting with @stereotype441 at length yesterday, I'm pretty convinced that getting this right depends on solving the larger issue of proper context creation for enumerated files (https://github.com/dart-lang/analyzer_cli/issues/53) which is gated by the much discussed ContextManager rework (#24133).

@kevmoo kevmoo added P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) and removed Priority-Medium labels Mar 1, 2016
@ghost
Copy link

ghost commented May 28, 2016

How would one work around this with the sublime text 3 dart plugin? Even if I launch sublime from the directory of the project, I get the "target of uri does not exist" error. Doing an analysis via cli command in the project dir works fine.

@ghost
Copy link

ghost commented May 28, 2016

Oops, turns out I did a pub get as root, but am using sublime as a user, so the files in .pub-cache had permissions preventing the normal user from accessing package files. A chown of those files to the user has fixed the errors for sublime. Sorry for the noise.

@srawlins
Copy link
Member

This is either solved, or just not a context we plan to support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
legacy-area-analyzer Use area-devexp instead. P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

5 participants