question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Saving pubspec.yaml does not run analysis server and unable to import new package.

See original GitHub issue

Describe the bug After adding a package in pubspec.yaml and saving the file analysis server do not analyze changes and we can not import newly added package.

To Reproduce Steps to reproduce the behavior:

  1. Add new package in pubspec.yaml
  2. Save the file with ctrl+s
  3. It will download the library but does not load new files/packages so we need to manually restart analysis server or restart vs code.

Expected behavior After saving and downloading package we should be able to import newly added package without needing to restart vs code or analysis server.

Screenshots I will provide if needed.

Versions (please complete the following information):

  • VS Code:
    Commit: 054a9295330880ed74ceaedda236253b4f39a335
    Date: 2021-06-18T02:30:22.835Z 
    Electron: 12.0.12
    Chrome: 89.0.4389.128
    Node.js: 14.16.0
    V8: 8.9.255.25-electron.0
    OS: Linux x64 5.12.13-arch1-2
  • Flutter:
[✓] Flutter (Channel stable, 2.2.2, on Linux, locale en_US.UTF-8)
   • Flutter version 2.2.2 at /opt/flutter
   • Framework revision d79295af24 (3 weeks ago), 2021-06-11 08:56:01 -0700
   • Engine revision 91c9fc8fe0
   • Dart version 2.13.3

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
   • Android SDK at /home/hatman/Android/Sdk
   • Platform android-30, build-tools 30.0.3
   • Java binary at: /opt/android-studio/jre/bin/java
   • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
   • All Android licenses accepted.

[✓] Chrome - develop for the web
   • CHROME_EXECUTABLE = /usr/bin/google-chrome-stable

[✓] Android Studio (version 4.1)
   • Android Studio at /opt/android-studio
   • Flutter plugin version 57.0.2
   • Dart plugin version 202.8531
   • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[✓] Connected device (2 available)
   • POCO F1 (mobile) • c7ca2666 • android-arm64  • Android 11 (API 30)
   • Chrome (web)     • chrome   • web-javascript • Google Chrome 91.0.4472.114

• No issues found!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:29 (13 by maintainers)

github_iconTop GitHub Comments

2reactions
DanTupcommented, Jan 18, 2022

I believe this issue is the same cause as #3438 which is that the server starts rebuilding contexts after the pubspec.yaml change and during the rebuild (which rebuilds file watchers) it misses the package_config.json change (having read the previous contents).

That issue is fixed by https://github.com/dart-lang/sdk/commit/650b9627b7a7c05d9d2a489a23b2eae98c9aef95 which is in the SDK so will show up in a future SDK release.

If you continue to see this after that change goes out and you’ve upgraded, please let me know!

1reaction
2shrestha22commented, Jul 25, 2021

@DanTup Sorry I missed the notification about this issue and today I did a look and found your reply.

I have attached a gif which explains my problem. It is not happening to me only but one of my friend is facing this problem too. cant-import-at-first At last a step is skipped in the gif. What I did in the last step is: commented the package and saved, then again umcommented and saved. And finally I got it working.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Flutter packages get does not install new package
Enter,spaces, and back spaces matter in pubspec.yaml File. ... Dart Packages, you need to run --> flutter pub cache repair This will ...
Read more >
Using packages
Depend on it. Open the pubspec. · Import it. Add a corresponding import statement in the Dart code. · Stop and restart the...
Read more >
Package dependencies
Dependencies are one of the core concepts of the pub package manager. A dependency is another package that your package needs in order...
Read more >
Dart | IntelliJ IDEA Documentation
Open the Marketplace tab, find the Dart plugin, and click Install (restart the IDE if prompted). Downloading the Dart tools. Download and ...
Read more >
How to Import Local Package in Flutter?
Flutter packages are open-source libraries that can be used by anyone at no ... into our pubspec.yaml file in our development environment.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found