Skip to content

Having folders from both Dart SDK repo and non-Dart SDK repo in the workspace fails to disable functionality like "dart test" for the SDK repo projects #4011

Closed

Description

@jcollins-g

Is your feature request related to a problem? Please describe.
There exist repositories of dart code that contain pubspec.yaml files, but where it is almost never the right choice to actually run dart pub get. An example of this is the Dart SDK repository, directories under pkg: https://github.com/dart-lang/sdk/tree/main/pkg. Some of these directories contain pubspec.yaml files, but under normal circumstances the workflow for editing them depends on externally constructed .dart_tool directories checked in at the top level which would be overridden by pub get. Some contain pubspec.yaml files that do not reference real packages, as well.

In addition, it can be desirable to manually edit and control .dart_tool directories while developing. Without a way to shut off modifying them via dart pub get, those workflows are disallowed.

Describe the solution you'd like
A configuration option that allows the user to stop dart pub get runs from happening when using the automatic Run | Debug options for tests and main() functions. As well, if pub get fails, the user could be prompted to ignore this. This could be implemented with a simple on/off switch, or a configuration option to change what is run when fetching packages so Dart could be replaced with /bin/true. Other possibilities abound.

Describe alternatives you've considered
-- see above --

Additional context
IntelliJ allows you to semi-permanently ignore pub get failures when they occur, which is compatible with my workflow.

Activity

  1. added
    is enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.
    on Jun 8, 2022
  2. DanTup commented on Jun 9, 2022

    @DanTup
    Member

    There is an existing setting to disable running pub get when you modify pubspecs:

    Screenshot 2022-06-09 at 10 38 33

    Additionally, we detect certain types of workspaces and disable this (along with the initial prompt). These include Bazel/Fuchsia workspaces (those with WORKSPACE or .jiri_root files), and also the Dart SDK repo itself.

    Is it one of these workspaces you're seeing this in (and if so, is it fetching when you save a pubspec, or just prompting you to run it at project load?). It would be nice if there was a define way for these types of projects to mark themselves (so the user doesn't need to change settings, or we have to guess), like a flag in pubspec.yaml (or some key in .dart_tool/package_config.json?) though I don't know how feasible that is.

  3. added
    awaiting infoRequires more information from the customer to progress
    on Jun 9, 2022
  4. jcollins-g commented on Jun 9, 2022

    @jcollins-g
    Author

    This is the Dart SDK repo, subdirectory pkg/analysis_server. Attempting to click on "Run" or "Debug" for any test within results in this problem. The indicated option of Run Pub Get On Pubspec Changes does not help with this.

    While auto-detection would be nice, the ability to control manually whether my workspace is modified is the most important part of this bug.

  5. DanTup commented on Jun 9, 2022

    @DanTup
    Member

    This turns out to be caused by having both SDK-repo and non-SDK-repo folders in the workspace. Flags that decide whether you're in the SDK are currently workspace-wide, and we use the first matching folder (any with a .git folder in the case of the SDK check).

    As a short-term workaround, removing the non-SDK folders from the workspace solves the issue. We should handle this better though (which may mean some flags that are currently workspace-wide, need to be tied to WorkspaceFolders).

  6. added and removed
    is enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.
    awaiting infoRequires more information from the customer to progress
    on Jun 9, 2022
  7. added this to the v3.44.0 milestone on Jun 9, 2022
  8. changed the title [-]Allow disabling of automatic `dart pub get` runs within Dart subdirectories[/-] [+]Having folders from both Dart SDK repo and non-Dart SDK repo in the workspace fails to disable functionality like "dart test" for the SDK repo projects[/+] on Jun 9, 2022
  9. DanTup commented on Jun 13, 2022

    @DanTup
    Member

    Tracking all of these settings individually per-WorkspaceFolder is quite tricky, because some of the settings affect workspace-wide things (like the Flutter daemon, or whether to use LSP). So for now I'm going to fix this in a simpler way. Rather than bailing out of the SDK search when we first find a .git folder, we'll do the checks for the README.dart-sdk file as part of the search (which means if we see a non-SDK git folder, we'll still enumerate the others).

    The impact of this is that the things disabled for the SDK (pub functionality, CodeLens per-test, etc.) will also be disabled for other WorkspaceFolders in the same window. I don't believe it will cause any issues this way, it will just be slightly more restrictive than it could be.

    We can revisit this is this setup becomes more common (or if it seems like it has introduced issues, or turns out to be more annoying than I'm anticipating).

  10. added a commit that references this issue on Sep 2, 2025
    d465ed9
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

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions