Skip to content

Unexpected prompt to select a package when saving pubspec.yaml for Pub Workspaces if root is outside of open folders #5563

Closed

Description

@DanTup

In this Flutter workspace, when I save bots/pubspec.yaml I'm prompted to run pub get in which folder. This should be automatic for the project where I just saved!

Image

Activity

  1. added this to the v3.114.0 milestone on Jun 24, 2025
  2. added
    in commandsRelates to commands (usually invoked from the command Palette)
    on Jun 24, 2025
  3. DanTup commented on Jun 25, 2025

    @DanTup
    MemberAuthor

    The same happens when opening the project and it prompts to run pub get. Clicking "Run pub get" results in a prompt.

  4. changed the title [-]Unexpected prompt to select a package when saving pubspec.yaml[/-] [+]Unexpected prompt to select a package when saving pubspec.yaml for Pub Workspaces if root is outside of open folders[/+] on Jun 25, 2025
  5. DanTup commented on Jun 25, 2025

    @DanTup
    MemberAuthor

    This happened because when selecting a project root, we only consider folders inside the workspace. However with Pub Workspaces, the project root (the target for running "pub get" can now be the workspace root instead of the nested project).

    I've applied a fix to getFolderToRunCommandIn but we may need to review all uses of locateBestProjectRoot to see whether this restriction is useful. It's been there for 9 years and unclear if really required.

    Dart-Code/src/project.ts

    Lines 20 to 22 in 02b7f9f

    // Make sure the current file is under the root.
    if (!file.startsWith(root))
    return root;

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

    in commandsRelates to commands (usually invoked from the command Palette)is bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions