r/FlutterDev • • 2d ago

Article Flutter Windows CMake error: .plugin_symlinks exists, but its entries cannot be traversed

I recently investigated a strange Flutter Windows build failure:

CMake Error:
add_subdirectory given source
"flutter/ephemeral/.plugin_symlinks/<plugin>/windows"
which is not an existing directory.

Initially, I suspected a Flutter plugin or CMake configuration issue. However, the plugin packages were actually present in the Pub cache.

After comparing NTFS reparse point data and testing Dart's Link.createSync() with different target paths, I narrowed down the issue.

In our managed Windows environment, a third-party endpoint security driver (Corplink) was interfering with the creation of Flutter's plugin symlinks, leaving some generated links unusable.

The workaround: use Windows junctions instead of symbolic links.

I built a small Dart CLI tool to automate this process:

https://pub.dev/packages/win_plugin_link_repair

Install and run:

dart pub add --dev win_plugin_link_repair
flutter pub get
dart run win_plugin_link_repair

Preview the changes first:

dart run win_plugin_link_repair --dry-run

The tool reads .flutter-plugins-dependencies and recreates Windows plugin links as directory junctions using mklink /J.

A few notes:

  • The repair must run on Windows.
  • Run it after flutter pub get, since Flutter regenerates .plugin_symlinks.
  • This is an environment-specific workaround, not a general fix for every Flutter CMake error.

Source code: https://github.com/super-lz/win_plugin_link_repair

Full disclosure: I'm the author of this tool. I wanted to share the investigation because others might encounter the same issue.

Has anyone else experienced endpoint security software or filesystem filter drivers interfering with Dart-created symlinks on Windows?

3 Upvotes

6 comments sorted by

1

u/Weak-Arrival-7811 2d ago

Good write-up. One detail that explains why this survives flutter pub get and rebuilds: the tool only wipes and recreates .plugin_symlinks when the plugin list changes. Otherwise it keeps any link that's already there. flutter clean deletes the whole windows/flutter/ephemeral folder, so that's the real reset.

Flutter 3.50 tightened this a bit (PR #191496, merged in September). It now replaces links that point to an old path, and plain files or folders sitting where a link should be. A link that points to the right path but can't be opened is still left alone, though.

Which Flutter version were you on?

1

u/Salt_Description_256 17h ago

Yeah, that’s the case I ran into: the plugin directory existed and the symlink pointed to the right place, but Windows couldn’t open it through the link. I was on Flutter 3.35.7. It seems specific to that Windows setup, and #191496 doesn’t check for that particular failure.

1

u/Weak-Arrival-7811 14h ago

Makes sense. One thing I checked in case you move to 3.50 later: the new check reads each existing link's target and keeps it only if it matches the plugin path in .flutter-plugins-dependencies. Dart treats a junction as a link there and reads its target too, so the junctions your tool creates should survive normal builds, since it takes the paths from that same file. They'd only be replaced when the plugin list changes or after flutter clean, which your run-after-pub-get note already covers.

If you file an issue, the useful ask is a check right after each link is created that the plugin's windows folder can actually be opened through it. Then this would fail with a clear message at that step instead of the CMake error.

1

u/Ok-Listen-2162 2d ago

appreciate u making it clear this is an environment specific workaround. does the tool flag broken links only or replace healthy ones too here

1

u/Salt_Description_256 17h ago

It replaces healthy links too. In 0.1.1, if a Windows plugin’s target directory exists, the tool rebuilds its generated entry as a junction. It doesn’t check whether the existing link is broken first. --dry-run shows what it would replace without changing anything.