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

flutter packages get not working in vs code #31115

Closed
surpriso1997 opened this issue Apr 16, 2019 · 32 comments
Closed

flutter packages get not working in vs code #31115

surpriso1997 opened this issue Apr 16, 2019 · 32 comments
Labels
waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds

Comments

@surpriso1997
Copy link

flutter packages get command or get packages button in vs code doesn't work. The packages are not installed but output has Exit code 0 after the execution of the command.

Steps to Reproduce

  1. Start a new project
  2. Add any package dependencies in pubspec file
  3. Run the project

Logs

flutter packages get
Running "flutter packages get" in e_commerce_app... 0.7s
exit code 0

@kuccilim
Copy link

exit code 0 indicate no errors..

@surpriso1997
Copy link
Author

exit code 0 indicate no errors..

Yes, but still the packages aren't downloaded.

@DanTup
Copy link
Contributor

DanTup commented May 1, 2019

@surpriso1997 can you confirm what you mean by "the packages aren't downloaded"? Where are you looking?

This operation should create (or update) a .packages file that will list all of the dependencies, along with paths to the versions of them in your pub cache (it will also download them to your pub cache). Can you confirm which bit of this doesn't seem to be working?

@DanTup DanTup added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label May 1, 2019
@devwithjp
Copy link

I'm facing the same issue. Any dependencies I include in the pubspec file doesn't seem to have any impact after doing flutter get, importing the respective packages gives a "Target of URI doesn't exist:" message.

@DanTup
Copy link
Contributor

DanTup commented May 8, 2019

@Fistus is there a .packages file, and does it contain references to the packages you added + paths to them in the pub cache?

Can you try running the Reload Window command in VS Code (or restarting it) and see if the red squiggles go away? (There's a known issue with newly-added packages not being picked up by the analysis server).

@devwithjp
Copy link

@DanTup There's a .packages file, however, it doesn't contain the references I had added. I tried restarting it as well.

@DanTup
Copy link
Contributor

DanTup commented May 8, 2019

Can you try:

  • deleting your .packages file
  • run the Dart: Capture Logs command in VS Code
  • right-click on pubspec.yaml in the VS Code's explorer
  • click "Get Packages"
  • wait for it to finish
  • click Stop Logging on the logging notification (it may have collapsed into the bell in the status bar)

Then attach the log.

@devwithjp
Copy link

@DanTup
Copy link
Contributor

DanTup commented May 9, 2019

@Fistus could you attach your pubspec.yaml file, along with the .packages file that gets created?

(Also, is there really a folder in your path named ' or did you just replace that out? If there is, does renaming it have any effect?)

@surpriso1997
Copy link
Author

@surpriso1997 can you confirm what you mean by "the packages aren't downloaded"? Where are you looking?

This operation should create (or update) a .packages file that will list all of the dependencies, along with paths to the versions of them in your pub cache (it will also download them to your pub cache). Can you confirm which bit of this doesn't seem to be working?

While writing import ' '; command in dart file it says target URL doesn't exist but running flutter get packages or clicking get packages in pubspec.yaml file yields exit code 0. Packages aren't downloaded in pub cache either.

@no-response no-response bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label May 9, 2019
@DanTup
Copy link
Contributor

DanTup commented May 9, 2019

@surpriso1997 Can you try

  • Deleting your .packages file
  • Running flutter packages get -v from the terminal in that folder
  • Attach your pubspec.yaml and the resulting .packages files here?

@Kalyanb447-github
Copy link

install this plug in on vs-code
Pubspec Assist
or download from hare
forom this link
https://marketplace.visualstudio.com/items?itemName=jeroen-meijer.pubspec-assist

click ctrl+shift+p connend pubspag
write your dependency
it will fix the error

@DanTup DanTup added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jun 14, 2019
@no-response
Copy link

no-response bot commented Jul 16, 2019

Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now. Please don't hesitate to comment on the bug if you have any more information for us; we will reopen it right away!
Thanks for your contribution.

@no-response no-response bot closed this as completed Jul 16, 2019
@rizzek
Copy link

rizzek commented Jul 17, 2019

I seem to experience the same bug.
I try to add the font_awesome_flutter dependency to a fresh pubspec.yaml and it seems to just get ignored.
When I delete the .packages file and/or the pubspec.lock they get recreated but still no font_awesome_flutter in there.

excerpt from pubspec.yaml

dependencies:
  flutter:
    sdk: flutter

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^0.1.2

  font_awesome_flutter: ^8.5.0

.packages:

# Generated by pub on 2019-07-17 22:41:13.484944.
async:file:///home/rizzek/.pub-cache/hosted/pub.dartlang.org/async-2.2.0/lib/
boolean_selector:file:///home/rizzek/.pub-cache/hosted/pub.dartlang.org/boolean_selector-1.0.4/lib/
charcode:file:///home/rizzek/.pub-cache/hosted/pub.dartlang.org/charcode-1.1.2/lib/
collection:file:///home/rizzek/.pub-cache/hosted/pub.dartlang.org/collection-1.14.11/lib/
cupertino_icons:file:///home/rizzek/.pub-cache/hosted/pub.dartlang.org/cupertino_icons-0.1.2/lib/
flutter:file:///home/rizzek/flutter/packages/flutter/lib/
flutter_test:file:///home/rizzek/flutter/packages/flutter_test/lib/
matcher:file:///home/rizzek/.pub-cache/hosted/pub.dartlang.org/matcher-0.12.5/lib/
meta:file:///home/rizzek/.pub-cache/hosted/pub.dartlang.org/meta-1.1.6/lib/
path:file:///home/rizzek/.pub-cache/hosted/pub.dartlang.org/path-1.6.2/lib/
pedantic:file:///home/rizzek/.pub-cache/hosted/pub.dartlang.org/pedantic-1.7.0/lib/
quiver:file:///home/rizzek/.pub-cache/hosted/pub.dartlang.org/quiver-2.0.3/lib/
sky_engine:file:///home/rizzek/flutter/bin/cache/pkg/sky_engine/lib/
source_span:file:///home/rizzek/.pub-cache/hosted/pub.dartlang.org/source_span-1.5.5/lib/
stack_trace:file:///home/rizzek/.pub-cache/hosted/pub.dartlang.org/stack_trace-1.9.3/lib/
stream_channel:file:///home/rizzek/.pub-cache/hosted/pub.dartlang.org/stream_channel-2.0.0/lib/
string_scanner:file:///home/rizzek/.pub-cache/hosted/pub.dartlang.org/string_scanner-1.0.4/lib/
term_glyph:file:///home/rizzek/.pub-cache/hosted/pub.dartlang.org/term_glyph-1.1.0/lib/
test_api:file:///home/rizzek/.pub-cache/hosted/pub.dartlang.org/test_api-0.2.5/lib/
typed_data:file:///home/rizzek/.pub-cache/hosted/pub.dartlang.org/typed_data-1.1.6/lib/
vector_math:file:///home/rizzek/.pub-cache/hosted/pub.dartlang.org/vector_math-2.0.8/lib/
rescue_buddy:lib/

@DanTup
Copy link
Contributor

DanTup commented Jul 18, 2019

@rizzek please open an issue at https://github.com/Dart-Code/Dart-Code and attach your pubspec.yaml in full (or if possible, an exact sample repo/folder you see this on), as well as the output you see from VS Code when it fetches the packages. Thanks!

@rizzek
Copy link

rizzek commented Jul 18, 2019

@DanTup Sure, will do once I encounter this bug again. I got it to work for now with a lot of fiddling around and deleting/installing stuff.
Thanks for clarifying where to report it. :)

@lukasschneiderapps
Copy link

lukasschneiderapps commented Aug 10, 2019

In my case "flutter clean" and restarting VS Studio Code fixed it.

@OpeyemiSanusi
Copy link

OpeyemiSanusi commented Oct 22, 2019

Remove the package(s) giving you the error from your pubspec.yaml run get when it's done type in the packages again and save the file. Run Flutter: Clean Project then when it's done close all Vscode window then open it again. It should show you a prompted message that some packages are missing, click on the get packages button.
Check your .packages file the package should be there but it could still show you Target URI missing you'd have to just keep erasing and typing that URI till it shows you a suggestion. It's a weird and annoying bug

@Khane1
Copy link

Khane1 commented May 4, 2020

I know this is way overdue but for the sake of anyone that may come after this,
in case you try to do everything and it fails you can do it manually simply download the files from GitHub and replace the files in the pub cache directory
flutter.pub-cache\hosted\pub.dartlang.org
especially if the lib file is not being found.
To confirm that the file is not found like @DanTup mentioned somewhere above

  1. check your .packages file
  2. See if the package file is found by holding control key and clicking the link.
  3. If the result is "file is a directory" then this next step won't help but in case it isn't found,
  4. Look for your flutter folder ,in your local drive wherever it may be, then follow this route
    'flutter.pub-cache\hosted\pub.dartlang.org'
  5. In there you will find all the packages you previously installed.
  6. Search for the exact package file giving you trouble and confirm that it is either completely not found, or missing the lib file.
  7. Get to pub.dart find the package you are looking for ,check for the Repository(GitHub) and then download the files.
  8. Extract and replace the files in the directory at step 4.
  9. Restart vsCode, and retype the links incase they still have the same red bottom line.
    Hope this helps.
    And thanks to everyone that contributed to this Repo.

@kishan2612
Copy link

I know this is way overdue but for the sake of anyone that may come after this,
in case you try to do everything and it fails you can do it manually simply download the files from GitHub and replace the files in the pub cache directory
flutter.pub-cache\hosted\pub.dartlang.org
especially if the lib file is not being found.
To confirm that the file is not found like @DanTup mentioned somewhere above

  1. check your .packages file
  2. See if the package file is found by holding control key and clicking the link.
  3. If the result is "file is a directory" then this next step won't help but in case it isn't found,
  4. Look for your flutter folder ,in your local drive wherever it may be, then follow this route
    'flutter.pub-cache\hosted\pub.dartlang.org'
  5. In there you will find all the packages you previously installed.
  6. Search for the exact package file giving you trouble and confirm that it is either completely not found, or missing the lib file.
  7. Get to pub.dart find the package you are looking for ,check for the Repository(GitHub) and then download the files.
  8. Extract and replace the files in the directory at step 4.
  9. Restart vsCode, and retype the links incase they still have the same red bottom line.
    Hope this helps.
    And thanks to everyone that contributed to this Repo.

Thanks man. Helped me and working

@dilnozacs
Copy link

I know this is way overdue but for the sake of anyone that may come after this,
in case you try to do everything and it fails you can do it manually simply download the files from GitHub and replace the files in the pub cache directory
flutter.pub-cache\hosted\pub.dartlang.org
especially if the lib file is not being found.
To confirm that the file is not found like @DanTup mentioned somewhere above

  1. check your .packages file
  2. See if the package file is found by holding control key and clicking the link.
  3. If the result is "file is a directory" then this next step won't help but in case it isn't found,
  4. Look for your flutter folder ,in your local drive wherever it may be, then follow this route
    'flutter.pub-cache\hosted\pub.dartlang.org'
  5. In there you will find all the packages you previously installed.
  6. Search for the exact package file giving you trouble and confirm that it is either completely not found, or missing the lib file.
  7. Get to pub.dart find the package you are looking for ,check for the Repository(GitHub) and then download the files.
  8. Extract and replace the files in the directory at step 4.
  9. Restart vsCode, and retype the links incase they still have the same red bottom line.
    Hope this helps.
    And thanks to everyone that contributed to this Repo.

thank you so much! it finally worked

@DanTup
Copy link
Contributor

DanTup commented May 18, 2020

Extract and replace the files in the directory at step 4.

Manually managing files in your pub cache doesn't seem like a good solution. If running flutter packages get is not correctly downloading to the pub cache and without a clear error indicating why, I would file a bug in the Pub repo with details.

@DanTup
Copy link
Contributor

DanTup commented May 20, 2020

@samar-1601 someone experiencing the issue that is able to respond to questions/requests for info would be better opening the issue. There isn't enough info here to troubleshoot, so it's going to need someone to post output/files to help debug.

@cesolutions
Copy link

I am also receiving this issue. It's been about a year, has there been a concrete fix solution yet?

@DanTup
Copy link
Contributor

DanTup commented Jun 8, 2020

@cesolutions others reporting this above resolved their issues so it's not clear what the problem was. If you're having issues, please open a new issue with the details (and include the info mentioned in the comments above). Feel free to cc me on it.

@Zyon900
Copy link

Zyon900 commented Jun 8, 2020

Since I encountered this recently, here is what causes the problem:

Visual Studio Code does NOT automatically save your pubspec.yaml file when running pub get.

You can fix the problem of it not getting packages by simply going to File>Save (Ctrl+S), after making changes to it, and before running pub get.

@DanTup
Copy link
Contributor

DanTup commented Jun 11, 2020

Visual Studio Code does NOT automatically save your pubspec.yaml file when running pub get.

That's correct - but by default it does the opposite - run pub get when you save your pubspec.yaml. So unless you've disabled that, there should be no need to run pub get manually when changing your pubspec.

@cesolutions
Copy link

I am using Android Studio and seeing this issue. I will create a new issue on here though.

@roonish
Copy link

roonish commented Jun 29, 2020

I guess everyone in this comment are genious lol.what an unnecessary way they are referring.
Those who need help

  1. simply go to pubspec. Yaml
  2. add your package dependency
  3. ctrl+s
    4)import the package
    Simple as it is. 🙏👍

@UsamaKarim
Copy link

Since I encountered this recently, here is what causes the problem:

Visual Studio Code does NOT automatically save your pubspec.yaml file when running pub get.

You can fix the problem of it not getting packages by simply going to File>Save (Ctrl+S), after making changes to it, and before running pub get.

This one worked for me. After trying every solution here this one worked for me. I even uninstalled the VS code and tried reinstalling many times nothing worked for me. Even clean install of VS code not work.
Thank you

@aspiiire
Copy link

aspiiire commented Jun 26, 2021

For me worked by simply Deleting .packages then runnin flutter clean

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds
Projects
None yet
Development

No branches or pull requests