sdk
sdk copied to clipboard
[CP] Imports can't be found by analyzer inside a bazel workspace
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.
@vsmenon @jacob314 @Hixie could you take a look at this cherry-pick?
@jacob314 this may be your area.
cc @zanderso
LGTM on the cherry pick. I've filed a separate issue for the right long term solution.
Approving this cherry-pick, thank you for the input @jacob314
This commit has been cherry-picked in 2.18.0-271.7.beta (0283de5506a5bd7d0e63e2092bf53ec93adddbd1).