-
Notifications
You must be signed in to change notification settings - Fork 294
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
Comments
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! |
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. |
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. 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. |
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). |
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.
|
Thanks! Can you clarify a few things:
I'm not sure exactly how the analyzer decides whether to import with a relative path versus a |
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 |
The Flutter extension won't make any difference here - all of the analysis work is inside the Dart extension. The |
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
FYI: The problem persists. Thanks so much for looking into this so quickly. |
Can you try this:
I wonder if the |
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 (CompilationUnitElementImpl) |
Hello, 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. Below is the output of
|
@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 |
Absolutely same issue, just upgrade flutter to latest version. |
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...) |
@DanTup is everyone seeing this using Flutter downloaded via the zip file - YES |
@DanTup Sample: |
Thanks - I've downloaded the zip version and created a project using it. My
However I'm still seeing @fryette I think your last sample is working correctly - the file you're importing isn't inside the |
@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. |
Oh, something else to check if you're having this - do you have file at @fryette in your example, there is no I am trying to use the the Quick-Fix to add missing imports, and it's showing |
Could you please try this example #2172 (comment) ? can we make a chat/call somewhere? To find issue faster? my package_config.json |
@fryette I didn't understand that example - there's no lib folder, so the quick fix couldn't generate a If you have Discord, we have chat at https://discord.gg/xSTPEqm |
And could you confirm the Flutter versions you're all using? I assumed the new stable, but I just noticed |
Thanks! |
I tried on If you haven't already, can you try deleting (or copying somewhere so if it works we can compare) all of |
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? |
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).
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). |
Thanks for that! I was aware of the problems with mixing import types and had chosen to always use
My project. I did what you suggested and deleted all of |
Oh, I misunderstood! In that case, I'm curious about the difference in |
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..
|
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 |
update: the same issue returned for me but so far, deleting |
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). |
Hi All. I can also report, deleting the Thx Rob |
@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.
|
Looks like this may have been tracked down: Sounds like running Flutter web apps may generate files that trigger different behaviour in the analysis server. There's a fix out for review. |
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. |
The fix is in the dart sdk now - it hasn't yet rolled to flutter master. As a short-term workaround, deleting |
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. |
@robwafle that's correct - see @devoncarew's comment above. When you run for the web it's creating some files in 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. |
The above PR has rolled into The version I tested with is:
|
I have installed fresh sdk files and now its working fine... |
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! |
I think this problem is generated because of the broken path in the plugins. Else |
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'. Never convertPlatformException(Object exception, StackTrace stackTrace) { FAILURE: Build failed with an exception.
BUILD FAILED in 1m 34s |
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
The text was updated successfully, but these errors were encountered: