Skip to content

Never follow symlinks in workspace globs - #4949

Merged
sigurdm merged 2 commits into
dart-lang:mainfrom
spydon:workspace-glob-follow-links
Nov 2, 2026
Merged

sigurdm merged 2 commits into
dart-lang:mainfrom
spydon:workspace-glob-follow-links

Conversation

@spydon

@spydon spydon commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Workspace globs follow symlinks. In a Flutter app with desktop platform folders, flutter pub get creates plugin symlinks such as linux/flutter/ephemeral/.plugin_symlinks/<plugin>. A glob like packages/** matches those, and because the plugins have no resolution: workspace, the next pub get fails:

packages/app/linux/flutter/ephemeral/.plugin_symlinks/plugin/pubspec.yaml is included in the workspace from ./pubspec.yaml, but does not have `resolution: workspace`.

The only workaround is to replace ** with a list of fixed depths, such as packages/* and packages/*/*, as Flame had to do.

Solution

Workspace globs no longer follow or match symlinks. followLinks: false alone isn't enough, because package:glob still returns the symlink itself and its pubspec.yaml is still found through the link, so anything that isn't a directory is skipped too.

Symlinked packages can still be members by listing them as literal entries, since those don't go through Glob. A package that was only picked up through a symlink in a glob needs that literal entry after this change.


  • I’ve reviewed the contributor guide and applied the relevant portions to this PR.
Contribution guidelines:

Many Dart repos have a weekly cadence for reviewing PRs - please allow for some latency before initial review feedback.

Note: The Dart team is trialing Gemini Code Assist. Don't take its comments as final Dart team feedback. Use the suggestions if they're helpful; otherwise, wait for a human reviewer.

@sigurdm sigurdm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for tracking this down and putting together a clean PR!

I'm hesitant to add {glob: ..., follow_links: bool} to the pubspec.yaml schema for this. Nobody writing workspace: [packages/**] actually wants pub to follow Flutter's .plugin_symlinks into ~/.pub-cache (or follow symlink cycles in example/ apps), so requiring users to hit the failure and opt into follow_links: false feels like exposing a workaround in configuration rather than fixing the default behavior.

Instead of introducing new pubspec.yaml syntax and a language version gate, what if workspace glob expansion in Package.load simply never follows symlinks (followLinks: false and if (globResult is! Directory) continue;)?

  • Literal workspace entries (workspace: [pkgs/external]) don't go through Glob (since #4852), so explicitly listed symlinked packages would still work.
  • Passing followLinks: false and checking globResult is Directory when expanding globs avoids following .plugin_symlinks / .symlinks (and avoids stating pubspec.yaml on regular files matched by **) with no config needed.

(As a side note, packages/* and packages/*/* is generally preferable to packages/** in large repos anyway, because ** forces package:glob to Directory.listSync(recursive: true) through every lib/, build/, .dart_tool/, and test/ folder under packages/.)

@spydon

spydon commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

@sigurdm that sounds like a better solution indeed, I'll update the PR!

@spydon spydon changed the title Add follow_links option to workspace globs Never follow symlinks in workspace globs Nov 2, 2026
@spydon
spydon changed the base branch from master to main November 2, 2026 13:04

@sigurdm sigurdm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@sigurdm
sigurdm merged commit af92fbe into dart-lang:main Nov 2, 2026
27 checks passed
sigurdm pushed a commit that referenced this pull request Nov 3, 2026
Follow-up to #4949.

`package:glob` steps straight into literal segments on case-sensitive platforms, so `followLinks: false` doesn't apply to them. With `linked/*`, where `linked` is a symlink, packages behind the link become workspace members. On Windows, globs are case-insensitive and every segment is listed, so the same pubspec doesn't pick them up.

Skip any glob match that is a symlink or is reached through one below the workspace root, so all platforms behave the same.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants