Skip to content
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

Import Quick Fix suggests relative paths to pub-cache instead of package: URIs #2172

Closed
robwafle opened this issue Dec 15, 2019 · 53 comments
Closed

Comments

@robwafle
Copy link

Hi.

I had to roll back to version 3.7.0 so I could continue to use the "Quick Fix" to add an import.

Quick fix no longer suggests a path starting with the package name as desired, it suggests some path ../../../pub_cache .. I've uninstalled it so I don't see that path now, but I think you can get the idea.

Thanks!

Rob

@DanTup
Copy link
Member

DanTup commented Dec 15, 2019

I can't reproduce this - and I'd be surprised if it was caused by the VS Code extension version, as the edits made by quick-fixes are built by the analyzer in the SDK and aren't modified by the extension.

If you can reproduce this, would you be able to capture a log? Thanks!

@DanTup DanTup added the awaiting info Requires more information from the customer to progress label Dec 15, 2019
@DanTup
Copy link
Member

DanTup commented Dec 15, 2019

Also, there only changes between v3.7.0 and v3.7.1 relate to URI mapping (v3.7.0...v3.7.1) so I don't think it going away is related to downgrading the extension. I would recommend upgrading again, and if you see it, grab a log.

@robwafle
Copy link
Author

robwafle commented Dec 15, 2019

Hi @DanTup! You're right. This does occur with v3.7.0 as well, but after the reinstall I was able to add references without issue. It started happening again today with v3.7.0. Maybe there's some cache being built in the background? I just know this started to happen over the weekend, so that's why I went with the rollback. I just upgraded to v3.7.1 again, and for the moment the suggestions are correct.

I have flutter installed in my user directory /Users/rob/dev/flutter .. and that is where the extension is now finding the classes to import. Flutter has been installed here and only here for months.
'../../../../../dev/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_redux-0.6.0/lib/flutter_redux.dart'

Please let me know if this is enough information, or if capturing the log will be helpful. It seems I have a workaround for now.

@robwafle robwafle changed the title Quick Fix now suggests wrong path when using v3.7.1 Quick Fix now suggests wrong path after some undermined amount of time when using v3.7.0 and v3.7.1 Dec 15, 2019
@robwafle robwafle changed the title Quick Fix now suggests wrong path after some undermined amount of time when using v3.7.0 and v3.7.1 Quick Fix suggests wrong path after some undermined amount of time when using v3.7.0 and v3.7.1 Dec 15, 2019
@DanTup
Copy link
Member

DanTup commented Dec 15, 2019

A log would definitly be helpful. And if would also be good to grab a full copy of the project you have open the next time you see it, and see if you can reproduce it after restarting VS Code (to figure out whether it's consistently reproducible given a set of files, or might be caused by some bad state the server has gotten into).

@DanTup DanTup changed the title Quick Fix suggests wrong path after some undermined amount of time when using v3.7.0 and v3.7.1 Quick Fix suggests wrong path after some undermined amount of time Dec 15, 2019
@DanTup DanTup changed the title Quick Fix suggests wrong path after some undermined amount of time Import Quick Fix suggests relative paths to pub-cache instead of package: URIs Dec 15, 2019
@robwafle
Copy link
Author

robwafle commented Dec 16, 2019

Looks like my workaround no longer works. I've uninstalled and re-installed a few different versions now and whatever is going on, that no longer resolves. it. The logs weren't so verbose so I'll just paste them inline here. I can't share the source for this project.

!! PLEASE REVIEW THIS LOG FOR SENSITIVE INFORMATION BEFORE SHARING !!

Dart Code extension: 3.7.1
Flutter extension: 3.7.0 (not activated)
VS Code: 1.41.0
Platform: mac
Workspace type: Flutter
Multi-root?: true
Dart SDK:
    Loc: /Users/rob/dev/flutter/bin/cache/dart-sdk
    Ver: 2.8.0-edge.45db29709547cf48f68344ba7abb8c1e6473e508
Flutter SDK:
    Loc: /Users/rob/dev/flutter
    Ver: 1.13.3-pre.23
HTTP_PROXY: undefined
NO_PROXY: undefined

Mon Dec 16 2019 [09:04:37 GMT-0600 (Central Standard Time)] Log file started
[9:04:41 AM] [Analyzer] [Info] ==> {"id":"23","method":"analysis.getHover","params":{"file":"/Users/rob/Documents/bulkmatic_tankwash/lib/utils/datehelper.dart","offset":49},"clientRequestTime":1576508681909}
[9:04:41 AM] [Analyzer] [Info] <== {"id":"23","result":{"hovers":[{"offset":44,"length":8,"staticType":"dynamic"}]}}
[9:04:42 AM] [Analyzer] [Info] ==> {"id":"24","method":"edit.getFixes","params":{"file":"/Users/rob/Documents/bulkmatic_tankwash/lib/utils/datehelper.dart","offset":44},"clientRequestTime":1576508682070}
[9:04:42 AM] [Analyzer] [Info] <== {"id":"24","result":{"fixes":[{"error":{"severity":"ERROR","type":"STATIC_WARNING","location":{"file":"/Users/rob/Documents/bulkmatic_tankwash/lib/utils/datehelper.dart","offset":70,"length":9,"startLine":2,"startColumn":36},"message":"The name 'Timestamp' isn't a type, so it can't be used in an 'as' expression.","correction":"Try changing the name to the name of an existing type, or creating a type with the name 'Timestamp'.","code":"cast_to_non_type","url":"https://dart.dev/tools/diagnostic-messages#cast_to_non_type","hasFix":true},"fixes":[{"message":"Import library '../../../../dev/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.12.11/lib/cloud_firestore.dart'","edits":[{"file":"/Users/rob/Documents/bulkmatic_tankwash/lib/utils/datehelper.dart","fileStamp":0,"edits":[{"offset":0,"length":0,"replacement":"import '../../../../dev/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.12.11/lib/cloud_firestore.dart';\n\n"}]}],"linkedEditGroups":[]},{"message":"Create class 'Timestamp'","edits":[{"file":"/Users/rob/Documents/bulkmatic_tankwash/lib/utils/datehelper.dart","fileStamp":0,"edits":[{"offset":113,"length":0,"replacement":"\n\nclass Timestamp {\n}"}]}],"linkedEditGroups":[{"positions":[{"file":"/Users/rob/Documents/bulkmatic_tankwash/lib/utils/datehelper.dart","offset":121},{"file":"/Users/rob/Documents/bulkmatic_tankwash/lib/utils/datehelper.dart","offset":70}],"length":9,"suggestions":[]}]},{"message":"Create mixin 'Timestamp'","edits":[{"file":"/Users/rob/Documents/bulkmatic_tankwash/lib/utils/datehelper.dart","fileStamp":0,"edits":[{"offset":113,"length":0,"replacement":"\n\nmixin Timestamp {\n}"}]}],"linkedEditGroups":[{"positions":[{"file":"/Users/rob/Documents/bulkmatic_tankwash/lib/utils/datehelper.dart","offset":121},{"file":"/Users/rob/Documents/bulkmatic_tankwash/lib/utils/datehelper.dart","offset":70}],"length":9,"suggestions":[]}]}]},{"error":{"severity":"ERROR","type":"STATIC_WARNING","location":{"file":"/Users/rob/Docum…
[9:04:46 AM] [Analyzer] [Info] ==> {"id":"25","method":"analysis.getHover","params":{"file":"/Users/rob/Documents/bulkmatic_tankwash/lib/utils/datehelper.dart","offset":73},"clientRequestTime":1576508686597}
[9:04:46 AM] [Analyzer] [Info] <== {"id":"25","result":{"hovers":[{"offset":70,"length":9}]}}
[9:04:46 AM] [Analyzer] [Info] ==> {"id":"26","method":"edit.getFixes","params":{"file":"/Users/rob/Documents/bulkmatic_tankwash/lib/utils/datehelper.dart","offset":70},"clientRequestTime":1576508686751}
[9:04:46 AM] [Analyzer] [Info] <== {"id":"26","result":{"fixes":[{"error":{"severity":"ERROR","type":"STATIC_WARNING","location":{"file":"/Users/rob/Documents/bulkmatic_tankwash/lib/utils/datehelper.dart","offset":70,"length":9,"startLine":2,"startColumn":36},"message":"The name 'Timestamp' isn't a type, so it can't be used in an 'as' expression.","correction":"Try changing the name to the name of an existing type, or creating a type with the name 'Timestamp'.","code":"cast_to_non_type","url":"https://dart.dev/tools/diagnostic-messages#cast_to_non_type","hasFix":true},"fixes":[{"message":"Import library '../../../../dev/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.12.11/lib/cloud_firestore.dart'","edits":[{"file":"/Users/rob/Documents/bulkmatic_tankwash/lib/utils/datehelper.dart","fileStamp":0,"edits":[{"offset":0,"length":0,"replacement":"import '../../../../dev/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.12.11/lib/cloud_firestore.dart';\n\n"}]}],"linkedEditGroups":[]},{"message":"Create class 'Timestamp'","edits":[{"file":"/Users/rob/Documents/bulkmatic_tankwash/lib/utils/datehelper.dart","fileStamp":0,"edits":[{"offset":113,"length":0,"replacement":"\n\nclass Timestamp {\n}"}]}],"linkedEditGroups":[{"positions":[{"file":"/Users/rob/Documents/bulkmatic_tankwash/lib/utils/datehelper.dart","offset":121},{"file":"/Users/rob/Documents/bulkmatic_tankwash/lib/utils/datehelper.dart","offset":70}],"length":9,"suggestions":[]}]},{"message":"Create mixin 'Timestamp'","edits":[{"file":"/Users/rob/Documents/bulkmatic_tankwash/lib/utils/datehelper.dart","fileStamp":0,"edits":[{"offset":113,"length":0,"replacement":"\n\nmixin Timestamp {\n}"}]}],"linkedEditGroups":[{"positions":[{"file":"/Users/rob/Documents/bulkmatic_tankwash/lib/utils/datehelper.dart","offset":121},{"file":"/Users/rob/Documents/bulkmatic_tankwash/lib/utils/datehelper.dart","offset":70}],"length":9,"suggestions":[]}]}]},{"error":{"severity":"ERROR","type":"STATIC_WARNING","location":{"file":"/Users/rob/Docum…
Mon Dec 16 2019 [09:04:50 GMT-0600 (Central Standard Time)] Log file ended

@DanTup
Copy link
Member

DanTup commented Dec 16, 2019

Thanks!

Can you clarify a few things:

  • Is this a Dart of Flutter project you have open?
  • Does VS Code show a Dart or Flutter version number in the status bar?
  • What does the path in your .packages file for cloud_firestore look like?
  • If you delete your .packages file and re-run pub: get packages and then check your .packages file again, is the path to cloud_firestore different to what it was before?

I'm not sure exactly how the analyzer decides whether to import with a relative path versus a package: URI, but maybe @bwilkerson has additional insight.

@robwafle
Copy link
Author

Hi Dan:

I have a flutter project open. I had to disable the flutter plugin to update the dart plugin. It is re-enabled now. I can capture a new log with the flutter plugin enabled if that would help. At the moment, it says Flutter: 1.13.3-pre.23. I'm on the master channel.

Interestingly, I don't see a .packages folder. I expected to see this in my project root, similar to node_modules, but it's not there. I also looked in my home dir. Where should I be looking for .packages?

Thanks!

Rob

@DanTup
Copy link
Member

DanTup commented Dec 16, 2019

The Flutter extension won't make any difference here - all of the analysis work is inside the Dart extension.

The .packages file should be inside your project folder (at the same level as pubspec.yaml). It may be hidden by default though. In Finder you can press Cmd+Shift+. to show hidden files/folders (I'm not sure what the defaults are for the VS Code explorer tree though - I do seem to see the file already in mine).

@robwafle
Copy link
Author

robwafle commented Dec 16, 2019

Ah, yes. It was there.. I actually prefer using my terminal for most things. I just started my day, and need more coffee.. I apologize, I deleted it before checking the path. More proof I need coffee.

Here are the contents of .package after running pub: get packages

# Generated by pub on 2019-12-16 10:11:13.664981.
aad_oauth:file:///Users/rob/dev/flutter/.pub-cache/git/aad_oauth-e89c33ad3f5d7dc71b3c705f3454612c0bfae2b3/lib/
analyzer:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/analyzer-0.38.5/lib/
archive:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/archive-2.0.11/lib/
args:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/args-1.5.2/lib/
async:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/async-2.4.0/lib/
boolean_selector:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/boolean_selector-1.0.5/lib/
build:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/build-1.2.2/lib/
build_config:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/build_config-0.4.1+1/lib/
build_daemon:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/build_daemon-2.1.2/lib/
build_resolvers:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/build_resolvers-1.2.1/lib/
build_runner:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/build_runner-1.7.2/lib/
build_runner_core:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/build_runner_core-4.2.0/lib/
built_collection:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/built_collection-4.3.0/lib/
built_value:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/built_value-7.0.0/lib/
charcode:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/charcode-1.1.2/lib/
checked_yaml:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/checked_yaml-1.0.2/lib/
cloud_firestore:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.12.11/lib/
cloud_functions:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_functions-0.4.1+6/lib/
code_builder:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/code_builder-3.2.1/lib/
collection:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/collection-1.14.11/lib/
convert:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/convert-2.1.1/lib/
crypto:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/crypto-2.1.3/lib/
csslib:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/csslib-0.16.1/lib/
cupertino_icons:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/cupertino_icons-0.1.3/lib/
dart_style:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/dart_style-1.3.3/lib/
firebase_analytics:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_analytics-5.0.6/lib/
firebase_auth:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth-0.15.0+1/lib/
firebase_core:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core-0.4.2/lib/
firebase_core_platform_interface:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-1.0.0/lib/
firebase_storage:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_storage-3.0.8/lib/
fixnum:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/fixnum-0.10.11/lib/
flutter:file:///Users/rob/dev/flutter/packages/flutter/lib/
flutter_barcode_scanner:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_barcode_scanner-0.1.7/lib/
flutter_redux:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_redux-0.6.0/lib/
flutter_secure_storage:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_secure_storage-3.3.1+1/lib/
flutter_test:file:///Users/rob/dev/flutter/packages/flutter_test/lib/
flutter_webview_plugin:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_webview_plugin-0.3.9+1/lib/
font_awesome_flutter:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/font_awesome_flutter-8.5.0/lib/
front_end:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/front_end-0.1.27/lib/
geolocator:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/geolocator-5.1.5/lib/
get_it:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/get_it-3.0.3/lib/
glob:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/glob-1.2.0/lib/
google_api_availability:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/google_api_availability-2.0.1/lib/
graphs:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/graphs-0.2.0/lib/
html:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/html-0.14.0+3/lib/
http:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.12.0+2/lib/
http_multi_server:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/http_multi_server-2.1.0/lib/
http_parser:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/http_parser-3.1.3/lib/
image:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/image-2.1.4/lib/
image_picker:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.6.2+1/lib/
intl:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/intl-0.16.0/lib/
io:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/io-0.3.3/lib/
js:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/js-0.6.1+1/lib/
json_annotation:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/json_annotation-3.0.0/lib/
json_serializable:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/json_serializable-3.2.3/lib/
kernel:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/kernel-0.3.27/lib/
location_permissions:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/location_permissions-2.0.3/lib/
logging:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/logging-0.11.3+2/lib/
matcher:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/matcher-0.12.6/lib/
meta:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/meta-1.1.8/lib/
mime:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/mime-0.9.6+3/lib/
node_interop:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/node_interop-1.0.3/lib/
node_io:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/node_io-1.0.1+2/lib/
package_config:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/package_config-1.1.0/lib/
package_info:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/package_info-0.4.0+12/lib/
package_resolver:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/package_resolver-1.0.10/lib/
path:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/path-1.6.4/lib/
pdf:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/pdf-1.3.24/lib/
pedantic:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/pedantic-1.8.0+1/lib/
petitparser:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/petitparser-2.4.0/lib/
pool:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/pool-1.4.0/lib/
printing:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/printing-2.1.8/lib/
pub_semver:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/pub_semver-1.4.2/lib/
pubspec_parse:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/pubspec_parse-0.1.5/lib/
quiver:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/quiver-2.0.5/lib/
quiver_hashcode:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/quiver_hashcode-2.0.0/lib/
redux:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/redux-4.0.0/lib/
redux_epics:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/redux_epics-0.12.0/lib/
redux_logging:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/redux_logging-0.4.0/lib/
rxdart:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/rxdart-0.22.6/lib/
scoped_model:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/scoped_model-1.0.1/lib/
shared_preferences:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.5.4+5/lib/
shelf:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/shelf-0.7.5/lib/
shelf_web_socket:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/shelf_web_socket-0.2.3/lib/
signature:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/signature-2.0.1/lib/
sky_engine:file:///Users/rob/dev/flutter/bin/cache/pkg/sky_engine/lib/
source_gen:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/source_gen-0.9.4+6/lib/
source_span:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/source_span-1.5.5/lib/
stack_trace:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/stack_trace-1.9.3/lib/
stream_channel:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/stream_channel-2.0.0/lib/
stream_transform:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/stream_transform-0.0.20/lib/
string_scanner:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/string_scanner-1.0.5/lib/
term_glyph:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/term_glyph-1.1.0/lib/
test_api:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/test_api-0.2.11/lib/
timing:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/timing-0.1.1+2/lib/
typed_data:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/typed_data-1.1.6/lib/
utf:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/utf-0.9.0+5/lib/
vector_math:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/vector_math-2.0.8/lib/
watcher:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/watcher-0.9.7+13/lib/
web_socket_channel:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/web_socket_channel-1.1.0/lib/
xml:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/xml-3.5.0/lib/
yaml:file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/yaml-2.2.0/lib/
bulkmatic_tankwash:lib/

FYI: The problem persists. Thanks so much for looking into this so quickly.

@DanTup
Copy link
Member

DanTup commented Dec 16, 2019

Can you try this:

  • run the Dart: Open Analyzer Diagnostics command
  • click Contexts on the left
  • search for cloud_firestore-0.12.11/lib/cloud_firestore.dart in the page (probably in the "implicit files" section?), and click the element link next to it
  • paste the contents here

I wonder if the Source doesn't have a package: URI there, though I think it should? I would've expected it to use the .packages file to realise that it could/should be a package: URI but I'm not totally familiar with this code so we might need some input from Brian.

@robwafle
Copy link
Author

Hi @DanTup here's that info:
/Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.12.11/lib/cloud_firestore.dart

/Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.12.11/lib/cloud_firestore.dart (CompilationUnitElementImpl)
┊ hasLoadLibraryFunction = false
┊ metadata = []
┊ nameOffset = -1
┊ source = Source (uri="file:///Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.12.11/lib/cloud_firestore.dart", path="/Users/rob/dev/flutter/.pub-cache/hosted/pub.dartlang.org/cloud_firestore-0.12.11/lib/cloud_firestore.dart")

@DanTup DanTup added this to the v3.8.0 milestone Dec 17, 2019
@thecodepapaya
Copy link

Hello,
I recently did a flutter upgrade and ran into a similar problem.

The auto-import function no longer imports from the URI but instead from the relative path. Upon selecting one of the options, we get a duplicate import apart from 'package: flutter/material.dart' and tons of ambiguity errors all over the code.

Here is a screenshot of the menu that appears upon hitting ctrl+space in VS code.

Screenshot from 2019-12-17 23-46-17

Below is the output of flutter doctor -v

[✓] Flutter (Channel master, v1.13.3-pre.44, on Linux, locale en_IN)
    • Flutter version 1.13.3-pre.44 at /home/ashutosh/flutter
    • Framework revision 86982e195e (2 hours ago), 2019-12-17 11:07:26 -0500
    • Engine revision bdd4e4d948
    • Dart version 2.8.0 (build 2.8.0-dev.0.0 fe9f30c389)

 
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /home/ashutosh/Android/Sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.2
    • Java binary at: /home/ashutosh/Downloads/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Android Studio (version 3.5)
    • Android Studio at /home/ashutosh/Downloads/android-studio
    • Flutter plugin version 41.0.2
    • Dart plugin version 191.8593
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] VS Code (version 1.41.0)
    • VS Code at /usr/share/code
    • Flutter extension version 3.7.1

[✓] Connected device (2 available)
    • Chrome     • chrome     • web-javascript • Google Chrome 79.0.3945.79
    • Web Server • web-server • web-javascript • Flutter Tools

• No issues found!

@DanTup
Copy link
Member

DanTup commented Dec 17, 2019

@bwilkerson @scheglov I've seen quite a few reports of this since the last Flutter stable update. I'm not sure whether it's likely something in the server that's changed, or something in Flutter. I'm guessing the .packages file is used for knowing which files map to package: URIs, but that file seems correct in the example above. Any ideas?

@fryette
Copy link

fryette commented Dec 18, 2019

Absolutely same issue, just upgrade flutter to latest version.
Same issue with Android Studio

@DanTup
Copy link
Member

DanTup commented Dec 18, 2019

Out of interest - is everyone seeing this using Flutter downloaded via the zip file (and not a direct Git clone)? And does this only occur in Flutter projects and not standalone Dart projects?

(Still trying to repro here...)

@fryette
Copy link

fryette commented Dec 18, 2019

@DanTup is everyone seeing this using Flutter downloaded via the zip file - YES
And does this only occur in Flutter projects and not standalone Dart projects? - Reproduced

@fryette
Copy link

fryette commented Dec 18, 2019

Screen Shot 2019-12-18 at 13 57 19

@DanTup
So the issue is reproduced for both cases(Dart and Flutter project)
If you are try to reference on file in folder to file out this folder.
On Screenshot above you can see structure, and in test file has next content:

Screen Shot 2019-12-18 at 13 58 47

Sample:
helloworld.zip

@DanTup
Copy link
Member

DanTup commented Dec 18, 2019

Thanks - I've downloaded the zip version and created a project using it. My .packages file now has paths pointing to the Flutter-shipped .pub-cache folder as the ones above do:

flutter:file:///Users/danny/Dev/Flutter%20SDKs/v1.12.13+hotfix.5/packages/flutter/lib/

However I'm still seeing package: URIs for the imports in quick-fixes. If there's anything else you think may be relevant to reproducing this, please let me know.

@fryette I think your last sample is working correctly - the file you're importing isn't inside the lib folder so it has no package: URI (package: URIs map into the lib/ folder of a package).

@fryette
Copy link

fryette commented Dec 18, 2019

@DanTup I attached Dart project(in previous comment), where all files contains in bin folder. But Quick fix stiil try to reference via absolute path.
Could you please confirm, that in your case, Quick Fix try to reference package instead of absolute path?

@DanTup
Copy link
Member

DanTup commented Dec 18, 2019

Oh, something else to check if you're having this - do you have file at .dart_tool/package_config.json? If so, what do the contents look like for the packages in question?

@fryette in your example, there is no lib folder, so it will have to use a relative path to import.

I am trying to use the the Quick-Fix to add missing imports, and it's showing package: URIs and not relative paths:

Screenshot 2019-12-18 at 11 04 33

@fryette
Copy link

fryette commented Dec 18, 2019

Could you please try this example #2172 (comment) ?

can we make a chat/call somewhere? To find issue faster?

my package_config.json
package_config.json.zip

@DanTup
Copy link
Member

DanTup commented Dec 18, 2019

@fryette I didn't understand that example - there's no lib folder, so the quick fix couldn't generate a package: URI for it.

If you have Discord, we have chat at https://discord.gg/xSTPEqm

@DanTup
Copy link
Member

DanTup commented Dec 18, 2019

And could you confirm the Flutter versions you're all using? I assumed the new stable, but I just noticed Ver: 1.13.3-pre.23 in one of the logs above - I may be testing the wrong version 🙈

@nickmeinhold
Copy link

  • Flutter downloaded via the zip file: yes, I think so
  • only occurs in Flutter projects and not standalone Dart projects: confirmed
  • flutter version: 1.13.3-pre.42 (issue has been there for the last few upgrades, all 1.13.3-preX I think)

Thanks!

@DanTup
Copy link
Member

DanTup commented Dec 18, 2019

I tried on a82a39973369db5101d5cae9ae674a1f75fcd3eb too, but no luck.

If you haven't already, can you try deleting (or copying somewhere so if it works we can compare) all of .dart_tool folder, .packages file, pubspec.lock and then reloading VS Code and running Flutter: Get Packages to see if the problem persists?

@nickmeinhold
Copy link

Oh that worked! Well, it changed things anyway - imports are working but for imports inside the project there is only the relative import option in the past I seem to remember always having both the package and the relative import options? When I say imports are working, all imports outside of the project are now offered as package imports rather than relative.

I copied the project folder before deleting things, as you suggested, if there's anything you want me to check?

@DanTup
Copy link
Member

DanTup commented Dec 18, 2019

imports are working but for imports inside the project there is only the relative import option in the past I seem to remember always having both the package and the relative import options?

My experience of this has been a little inconsistent. There are some open issues (for ex dart-lang/sdk#32916) around this, but I'm still not sure if there's a consensus for which is best (but mixing them can definitely cause issues).

I copied the project folder before deleting things, as you suggested, if there's anything you want me to check?

Your project, or Flutter? It was the Flutter folder I meant (since that's what you replaced?). If so, knowing what's different between the broken/working versions would help - though I don't know how easily you could diff that tree (and it may contain many differences if it's a slightly different version of Flutter anyway).

@nickmeinhold
Copy link

My experience of this has been a little inconsistent. There are some open issues (for ex dart-lang/sdk#32916) around this, but I'm still not sure if there's a consensus for which is best (but mixing them can definitely cause issues).

Thanks for that! I was aware of the problems with mixing import types and had chosen to always use package: I assumed the effective dart way had been chosen now and was about to embark on changing all my local imports to relative. I guess I'll hold off for now and see what happens.

Your project, or Flutter? It was the Flutter folder I meant (since that's what you replaced?). If so, knowing what's different between the broken/working versions would help - though I don't know how easily you could diff that tree (and it may contain many differences if it's a slightly different version of Flutter anyway).

My project. I did what you suggested and deleted all of .dart_tool folder, .packages file, pubspec.lock and then reloaded VS Code and ran Flutter: Get Packages. I didn't reinstall Flutter or do anything to the Flutter folder.

@DanTup
Copy link
Member

DanTup commented Dec 18, 2019

Oh, I misunderstood! In that case, I'm curious about the difference in .dart_tool/packages_config.json, .packages (and maybe pubspec.lock) between the now-working project, and the same files in the one that didn't work.

@robwafle
Copy link
Author

robwafle commented Dec 18, 2019

Hi All. I'd just like to comment that this morning, package imports are again working for some reason. Just the in-project imports are relative (which doesn't work for me.) Different paths to the same file, even with different case cause type resolution errors. I must always use an import starting with package:app_name: or things just blow up. Seems like something may have auto-updated itself. Here's the output of flutter doctor -v. Hopefully this helps nail this down..

[✓] Flutter (Channel master, v1.13.3-pre.60, on Mac OS X 10.15.1 19B88, locale en-US)
    • Flutter version 1.13.3-pre.60 at /Users/rob/dev/flutter
    • Framework revision ceef460a64 (6 hours ago), 2019-12-18 00:23:02 -0800
    • Engine revision 500f9cedf6
    • Dart version 2.8.0 (build 2.8.0-dev.0.0 2d332ee1d3)

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /Users/rob/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.3, Build version 11C29
    • CocoaPods version 1.8.4

[✓] Android Studio (version 3.5)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 42.1.1
    • Dart plugin version 191.8593
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] IntelliJ IDEA Ultimate Edition (version 2019.2.4)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    • Flutter plugin version 41.1.4
    • Dart plugin version 192.7402

[✓] VS Code (version 1.41.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.7.1

[✓] Connected device (1 available)
    • Android SDK built for x86 64 • emulator-5554 • android-x64 • Android 9 (API 28) (emulator)

• No issues found!```

@nickmeinhold
Copy link

Thanks Dan, I diffed the files you mentioned but there doesn't seem to be anything interesting. A couple of packages (firebase_auth and google_signin) got a minor version bump and the only other difference was the generated timestamp changed in .packages and .dart_tool/package_config.json. Is there a way I can put the diffs ups somewhere? I couldn't find a way. I don't think there's anything useful there anyway.

@nickmeinhold
Copy link

update: the same issue returned for me but so far, deleting .dart_tool again, restarting VSCode and running flutter pub get fixes it

@DanTup
Copy link
Member

DanTup commented Dec 19, 2019

If it does come back, grab a copy of the project before fixing, and then see if it still repros there after you fix the original (if so, there must be something different between the two, which might help track down what's happening). If you've already fetched packages recently, there shouldn't be many version number changes. If there's anything else different, let me know (even minor differences like trailing slashes on paths, trailing newlines in files etc. might be significant).

@robwafle
Copy link
Author

Hi All.

I can also report, deleting the .dart_tool folder and restarting visual studio code seems to have solved this problem. I'll report in if the issue re-occurs.

Thx

Rob

@nickmeinhold
Copy link

@DanTup - happened again and yes, the copied project continues to have the issue after the original is fixed. I diffed the projects but I don't see where the problem might be.

Screen Shot 2019-12-20 at 4 37 07 pm

  • the only difference for package_config.json and .packages is the timestamp
  • not sure where the other changes came from, maybe autocreated when running VSCode? I'm assuming not relevant anyway right?

@DanTup
Copy link
Member

DanTup commented Dec 20, 2019

Looks like this may have been tracked down:

dart-lang/sdk#39848 (comment)

Sounds like running Flutter web apps may generate files that trigger different behaviour in the analysis server. There's a fix out for review.

@efreibe
Copy link

efreibe commented Dec 20, 2019

I have a similar problem, in the dart context menu, inside a flutter project now it shows imports with relative paths.

It's not only related to the context menu, sometimes it autocompletes imports with relative ones even if I have an absolute import already defined in the source file, this ends giving a redefined symbol error.

Reinstalling the extension does not solve the problem.

image

@devoncarew
Copy link
Contributor

The fix is in the dart sdk now - it hasn't yet rolled to flutter master.

As a short-term workaround, deleting .dart_tool/build/ should work. That will get re-created each time you flutter run a web app.

@robwafle
Copy link
Author

Just a note. Deleting the .dart_tool folder and restarting vscode appears to be only a temporary workaround. Eventually the paths suggested will be wrong again.

@DanTup
Copy link
Member

DanTup commented Dec 23, 2019

@robwafle that's correct - see @devoncarew's comment above. When you run for the web it's creating some files in .dart_tool/build that are affecting how the analyzer resolves paths. You'll need to re-delete it each time you run (and may need to reload the project).

The SDK fix has rolled into the flutter/engine (flutter/engine@4c3cfcf) but that hasn't rolled into flutter/flutter yet. There's an open PR at flutter/flutter#47565 from the auto-roller (I'm not sure why it hasn't landed yet - it is green), but you can Subscribe to that PR if you want notification of when the fix is in master.

@DanTup
Copy link
Member

DanTup commented Dec 26, 2019

The above PR has rolled into master and the issue is resolved. If anyone still see this after pulling changes, please shout.

The version I tested with is:

danny@Dannys-MBP ~ % flutter --version
Flutter 1.13.6-pre.29 • channel master • git@github.com:DanTup/flutter.git
Framework • revision 2884758f50 (78 minutes ago) • 2019-12-26 11:59:45 -0800
Engine • revision 42bb7c9eea
Tools • Dart 2.8.0 (build 2.8.0-dev.0.0 c260e4e8da)

@DanTup DanTup closed this as completed Dec 26, 2019
@DanTup DanTup added fixed in dart / flutter and removed upstream in dart / flutter Needs changing in Dart or Flutter labels Dec 26, 2019
@DanTup DanTup removed this from the v3.8.0 milestone Jan 27, 2020
@shrawank039
Copy link

I have installed fresh sdk files and now its working fine...

@medz
Copy link

medz commented May 19, 2020

image
I encountered the same problem, auto import no longer works

@medz
Copy link

medz commented May 19, 2020

image

.paclage file

@DanTup
Copy link
Member

DanTup commented May 19, 2020

@medz

I encountered the same problem, auto import no longer works

This sounds like a different issue to this one, can you file a new issue and include exact details of what you're seeing? You mention auto-import but your screenshot shows a lot of code with unresolved symbols - auto-import is only when you use code-completion. Please describe exactly what you're doing and what you're expecting to see. Thanks!

@medz
Copy link

medz commented May 19, 2020

@DanTup I created a new issue: #2470

@Laxman-Kumar
Copy link

I think this problem is generated because of the broken path in the plugins.
Goto File -> Project Structure -> Click on Libraries on the left side -> click dart
If you see any broken paths try to fix them.

Else
Create a new project with AndroidX and try to move all your code and dependencies on the new project.
(This worked for me)

@Dhiraj1424
Copy link

Please help me

/D:/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth_platform_interface-6.2.0/lib/src/method_channel/utils/exception.dart:14:11: Error: Member not found: 'Error.throwWithStackTrace'.
Error.throwWithStackTrace(exception, stackTrace);
^^^^^^^^^^^^^^^^^^^
/D:/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth_platform_interface-6.2.0/lib/src/method_channel/utils/exception.dart:17:9: Error: Member not found: 'Error.throwWithStackTrace'.
Error.throwWithStackTrace(
^^^^^^^^^^^^^^^^^^^
/D:/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth_platform_interface-6.2.0/lib/src/method_channel/utils/exception.dart:12:7: Error: A non-null value must be returned since the return type 'Never' doesn't allow null.

Never convertPlatformException(Object exception, StackTrace stackTrace) {
^
2

FAILURE: Build failed with an exception.

Process 'command 'D:\src\flutter\bin\flutter.bat'' finished with non-zero exit value 1

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 1m 34s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests