sdk icon indicating copy to clipboard operation
sdk copied to clipboard

[CP] Imports can't be found by analyzer inside a bazel workspace

Open christopherfujino opened this issue 3 years ago • 4 comments

Commit(s) to merge

e4dd92c1088dd376e45de308f9b7dee5e4a70d49

Target

beta

Issue Description

For open source Dart/Flutter users, if they try to dart analyze a package that has a file named WORKSPACE in a parent directory but their dependencies were fetched with pub, analysis will fail to resolve dependencies.

What is the fix

Rather than favoring bazel workspace's over pub workspaces, instead choose the most specific (longest path).

Why cherry-pick

This regression has broken many Flutter customers:

  • https://github.com/flutter/flutter/issues/103706
  • https://github.com/flutter/flutter/issues/103895
  • https://github.com/flutter/flutter/issues/105398
  • https://github.com/Dart-Code/Dart-Code/issues/3972
  • https://github.com/Dart-Code/Dart-Code/issues/3976

Note, other tools than just Bazel create WORKSPACE files, many users reporting the issue had it for years at some top level directory.

Risk

low

Issue link(s)

https://github.com/flutter/flutter/issues/103706,https://github.com/flutter/flutter/issues/103895,https://github.com/flutter/flutter/issues/105398,https://github.com/Dart-Code/Dart-Code/issues/3972,https://github.com/Dart-Code/Dart-Code/issues/3976

Extra Info

This merges cleanly and unit tests pass for me locally.

christopherfujino avatar Jul 27 '22 22:07 christopherfujino

@vsmenon @jacob314 @Hixie could you take a look at this cherry-pick?

itsjustkevin avatar Jul 28 '22 01:07 itsjustkevin

@jacob314 this may be your area.

itsjustkevin avatar Aug 09 '22 13:08 itsjustkevin

cc @zanderso

christopherfujino avatar Aug 09 '22 20:08 christopherfujino

LGTM on the cherry pick. I've filed a separate issue for the right long term solution.

jacob314 avatar Aug 09 '22 21:08 jacob314

Approving this cherry-pick, thank you for the input @jacob314

itsjustkevin avatar Aug 10 '22 12:08 itsjustkevin

This commit has been cherry-picked in 2.18.0-271.7.beta (0283de5506a5bd7d0e63e2092bf53ec93adddbd1).

sortie avatar Aug 15 '22 11:08 sortie