Skip to content

Elevate messages from dart pub get #4256

Open

Description

@jonasfj

We put a lot of work into messages coming out of dart pub get.

We have messages like:

  • Current package version have been retracted.
  • Newer a.b.c version available.
  • Package is discontinued.
  • Package is discontinued, replaced by package:foo.
  • Summaries of changes.
  • Content hash from pubspec.lock doesn't match content from server (new in 2.19)
  • Package version affected by security advisory (coming in the future)

Perhaps we should start a conversation about how we can highlight this information to users.
Context: we sometimes discover that users run into issues that were fixed 2 months ago, because they never run dart pub upgrade, even after an SDK upgrade.

Maybe, improving messaging here could help.
This is just to open a discussion, maybe we'd want pub to have other output. Or maybe this is better injected through the LSP.

cc @sigurdm, @szakarias

Activity

  1. DanTup commented on Nov 9, 2022

    @DanTup
    Member

    Currently when we run "pub get" the output is hidden unless a) the process is still running after 10s or b) it exits with a non-zero exit code. In those cases, we show the Output pane that its output was being written to.

    We could change these triggers to show the output in more cases, although I'm not familiar enough to know how often the cases above occur. If we end up showing the Output pane almost every time we run, I think that could be annoying (users may be aware of these issues from the last time they ran it, and don't need reminding every time they modify pubspec - which triggers the run again).

    It would be nice if we could show some of this information in a more integrated way though. Perhaps we could run pub get --json or similar and have the usual output (that we can handle the same way we treat all of stdout today), but also have the items in a structured way that we can show elsewhere. For example, there's a new API I'd like to adopt soon that would let us move a lot of the information we have scattered around the place into a single flyout from the status bar:

    image

    Some of the things noted above (like a package you're using having a security advisory) might fit nicely there - we could show some kind id indicator on the status bar so it's noticable, but without popping open a pane of text output every time you fetch packages. (note: I haven't tried to use this API yet so I don't know its full capabilities/limitations).

  2. added
    is enhancement
    in commands
    on Nov 9, 2022
  3. added this to the On Deck milestone on Nov 9, 2022
  4. jonasfj commented on Nov 9, 2022

    @jonasfj
    Author

    For advisories, the idea is that users will be able to add ignored_advisories to pubspec.yaml.
    Such that you can declare that you've reviewed an advisory and don't care.
    So in that case, maybe we want LSP to add a warning for each import-statement, or adding warnings to pubspec.yaml. It would make a lot of noise, but it's also easy to fix, but just adding it to ignored_advisories (ideally, with a quick fix).

    But things like:

    • Discontinued package,
    • Newer version available,

    Maybe it's better for it just to be a subtle message that doesn't annoy users too much.

    I'm less certain about what level of noise we want for using a retracted package version. We have no explicit mechanism for declaring that you want a retracted version -- but you only get it, if it's in your pubspec.lock or in dependency_overrides.

  5. jonasfj commented on Nov 9, 2022

    @jonasfj
    Author

    One possibility is that dart pub get writes a .dart_tool/pub/dependency-summary.json that exposes these messages for analysis_server/lsp or IDEs to consume.

    Still not sure we want that: because for a message like "newer version available", it's legitimate to ignore it, yet there is no mechanism for stating that you don't care.

  6. DanTup commented on Nov 9, 2022

    @DanTup
    Member

    One possibility is that dart pub get writes a .dart_tool/pub/dependency-summary.json that exposes these messages for analysis_server/lsp or IDEs to consume.

    Having it on disk has some advantages - both the LSP server (which can produce diagnostics/quick-fixes) and the IDE (which may want to surface some of these things in specific ways that are UI/editor-specific and never likely to fall inside LSP) can access it without spawning (duplicate) commands (plus it removes some complexity of actually running commands, providing output to the user if the command fails/hangs, etc.). If we did this, we should ensure there's a timestamp in it so tell how fresh the data is (since unlike invoking a command directly, it could easily be stale and I'm not sure we want to rely on the file timestamps).

    For some things (like security advisories), I feel like the status bar with some coloured indicator could be good - however it's less simple to invoke a quick-fix from there because it's not driven by the analysis server. We could probably handle this with a well-known server command that could be invoked if you chose to ignore it though (which lets the server produce the pubspec edits).

    Is it worth trying to come up with an example of some JSON for the the kind of information you have for each of these? Perhaps some of them can be generalised (so the IDE/server don't need to quite know the specifics of every item if many of them will generally be treated the same, just with some different text/identifier).

  7. devoncarew commented on Nov 9, 2022

    @devoncarew
    Contributor

    In terms of having a place to display richer information, perhaps we could decorate the pubspec.yaml file when the user opens it? We could use synthetic labels after a package dep to display additional information about the package:

    dependencies:
      args: ^1.7.0 # on version 1.7.1; version 1.8.0 is available
      collection: ^1.0.0 # on version 1.2.3; version has been retracted!
      path: ^2.0.0 # on version 2.1.0
  8. DanTup commented on Nov 9, 2022

    @DanTup
    Member

    We could also use CodeLens to have clickable links to upgrade (the same Run/Debug links we show on main functions and tests/groups), though if there are likely to be many it might look a bit cluttered (they add extra space between lines of code, messing with the spacing).

    To have synthetic labels like we do for Closing Labels, we'd have to do something custom unless microsoft/vscode#151920 is implemented (so we could use the LSP-standard Inlay Hints without them being styled badly).

  9. mit-mit commented on Nov 10, 2022

    @mit-mit
    Contributor

    perhaps we could decorate the pubspec.yaml file when the user opens it

    That is an interesting option, but I personally find them confusing when they look exactly like actual comments.

  10. devoncarew commented on Nov 10, 2022

    @devoncarew
    Contributor

    That is an interesting option, but I personally find them confusing when they look exactly like actual comments.

    I've gotten used to them for the Flutter widget tree closing labels, but agree that they do need to look distinct from regular user code. It sounds like the subtle style used for closing labels isn't available to us currently though, just the a more bold / emphasized variant.

  11. stuartmorgan-g commented on Mar 9, 2023

    @stuartmorgan-g
    Contributor

    I would love to see a follow-up toast to the "run pub get?" toast if the output said any packages were out of date. While it may be annoying for some people, we see a lot of issues from people where the problem is that they just haven't run flutter pub upgrade to update transitive dependencies.

  12. DanTup commented on Mar 13, 2023

    @DanTup
    Member

    I would love to see a follow-up toast to the "run pub get?" toast if the output said any packages were out of date.

    For this specifically, we might already have what we need. There's a pub outdated --json that we could run after pub get. If any package listed has a higher upgradable than current, we could (with an option to turn on/off), prompt to run pub upgrade?

    @jonasfj is that logic correct?

    I also opened #4262 about possible showing summary of pub updated in the language status, although I'm not yet sure many people look in there except me when jumping between SDK versions 🙃

    FWIW, we do already prompt to pub upgrade when you go up an SDK version, but that's a special case.

  13. sigurdm commented on Mar 14, 2023

    @sigurdm

    is that logic correct?

    I think that would work. It will however do quite a lot of work compared to what is needed.

    pub get is optimized to just give a list of outdated/discontinued/retracted packages without doing more resolutions.
    @jonasfj should we consider an easy-to-parse json-output of pub get that will contain this information?

  14. DanTup commented on Mar 14, 2023

    @DanTup
    Member

    When we run pub get in the case above, we may end up showing the user the output (if it's taking too long, or if they open the Output pane and select it) so having a --machine flag of similar to give JSON probably won't work too well here.

    I think if there are going to be changes to pub to support this, this perhaps something like the above (writing a file like .dart_tool/pub/dependency-summary.json for a normal pub get) would be the better solution. That way we can still show the users the output, but we can also get a structured view of things when the process completes.

  15. modified the milestones: On Deck, Backlog on Dec 10, 2024
  16. DanTup commented on Aug 12, 2025

    @DanTup
    Member

    Is there still any interest/desire in making any changes here? There were some ideas above that would require pub to provide additional output in a structured form so I don't think there's anything we can do in the IDE without that being defined/implemented first.

  17. added
    awaiting info
    on Aug 12, 2025
  18. sigurdm commented on Aug 12, 2025

    @sigurdm

    I still think the idea is valid. But I'm not sure we have a lot of resources currently to implement it.

    Thinking about this now, we could perhaps surface security advisories the same way as analyzer warnings. The "outdated" ones should probably be more subtle.

    Always having pub output a timestamped .dart_tool/pub/resolution_findings.json sounds like a promising direction. It could contain findings from the last resolution, together with severities and locations in pubspec.yaml.

    Locations might sometimes be complicated though. A finding could be about a transitive dependency (no local pubspec.yaml to point to) or about a dependency shared between multiple workspace packages (multiple local pubspec.yaml files to point to). Should we really point to the pubspec.lock file? I don't know how often that is opened in the IDE.

    We could either codify fixed types of findings (outdated, discontinued, ...) and have the dart code plugin assign severities, or let pub define severities, and just have severity categories (info, warning, error).

    The design surface seems rather large...

  19. DanTup commented on Aug 12, 2025

    @DanTup
    Member

    We could either codify fixed types of findings (outdated, discontinued, ...) and have the dart code plugin assign severities, or let pub define severities, and just have severity categories (info, warning, error).

    I wonder if we should do this work in the analysis server instead? (cc @bwilkerson) Eg. pub writes the file, the analysis server reads it and produces diagnostics (this makes it ide-agnostic, and could even work from dart analyze at the CLI or in CI). Server has existing ways to configure severities in analysis_options.yaml so users could configure whether they want these and whether they're warnings/errots?

    I don't think using pubspec.lock as the location for transitive dependencies would be that bad - it would show up in the Problems list in the IDE, and could perhaps even have a fix for running something like pub upgrade?

  20. bwilkerson commented on Aug 12, 2025

    @bwilkerson

    Yes, we should always do as much work as possible in the analysis server so that all of our supported IDEs can benefit from that work. Server seems ideal for reporting diagnostics as well as for supporting relevant fixes.

    I also like the idea of using closing labels for additional information in the pubspec.

  21. github-actions commented on Sep 2, 2025

    @github-actions

    This issue has been marked stale because it is tagged awaiting-info for 20 days with no activity. Remove the stale label or comment to prevent the issue being closed in 10 days.

  22. added
    stale
    on Sep 2, 2025
  23. DanTup commented on Sep 2, 2025

    @DanTup
    Member

    @sigurdm is there (or should we open) a pub issue for this? I think having Pub create such a file is the first step before doing anything in the analysis server. Probably we should move this issue to the SDK (since we think this would be best done in analysis_server) but I don't know if it's worth doing that prior to the Pub work.

  24. sigurdm commented on Sep 2, 2025

    @sigurdm

    Feel free to open an issue.
    We probably need some work in figuring out the details of what goes into the file.

  25. DanTup commented on Sep 2, 2025

    @DanTup
    Member

    sgtm, I've opened dart-lang/pub#4663

  26. added
    blocked on dart / flutter
    and removed
    awaiting info
    stale
    on Sep 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    blocked on dart / flutterin commandsis enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions