AgoraIO-Extensions / AgoraIO-Extensions/Agora-Flutter-SDK

[Windows] Iris/Native SDK extraction fails under CMake 4.x (Visual Studio 2026): "Cannot extract through symlink"

Ouverte
#2,688 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
Dart
Étoiles
795
Forks
448
Merge moyen
12 h 19 min
PR mergées (30 j)
14

Description

Building for Windows fails during CMake configure as soon as Flutter picks Visual Studio 2026 instead of 2022. The cause is the CMake version bundled with each VS: 2022 ships CMake 3.31.6, 2026 ships **CMake 4.3.1**, and CMake 4.x refuses to extract an archive through a symlink (libarchive's `SECURE_SYMLINKS`).

Flutter reaches every plugin through `windows/flutter/ephemeral/.plugin_symlinks/`, which is a symlink into the pub cache. `DownloadSDK.cmake` extracts into `${CMAKE_CURRENT_SOURCE_DIR}/third_party/...`, so the extraction path runs straight through that symlink and CMake blocks it.

### Timing
Flagging this now rather than after the next release, since `dev/main` still looks affected, and a new release seems impending.

### Environment

| | |
|---|---|
| agora_rtc_engine | 6.6.3 |
| Flutter | 3.47.1 (stable) |
| OS | Windows 11 (10.0.26200) |
| Works | VS Community 2022 17.14 — bundled CMake 3.31.6 |
| Fails | VS Community 2026 18.9 — bundled CMake 4.3.1 |

Nothing else changed between the working and failing builds; installing VS 2026 alongside VS 2022 is enough, because Flutter's `vswhere -latest` query then selects 2026 and uses its CMake.

### Error

```
CMake Error: Problem with archive_write_header(): Cannot extract through symlink
\?\D:\projects\...\windows\flutter\ephemeral\.plugin_symlinks\agora_rtc_engine
CMake Error: Current file:
iris_4.6.2-build.1_DCG_Windows/
CMake Error: Problem extracting tar:
.../third_party/iris/iris_4.6.2-build.1_DCG_Windows_Video_Standalone_20260212_0947_31926.zip

CMake Warning at .../windows/cmake/DownloadSDK.cmake:93 (message):
IRIS_INCLUDE_DIR:
CMake Warning at .../windows/cmake/DownloadSDK.cmake:94 (message):
IRIS_LIB_DIR:
CMake Error at .../windows/cmake/DownloadSDK.cmake:95 (message):
Failed to find include directory and library directory of Iris SDK
```

### Reproduce

1. Install VS 2022 and VS 2026 side by side, both with "Desktop development with C++".
2. `flutter clean` in any app depending on `agora_rtc_engine`.
3. `flutter build windows`.

`flutter doctor -v` will show VS 2026 selected.

### Confirming it's the symlink and nothing else

Extracting the very same zip with the very same `cmake.exe` succeeds when the destination is the real pub-cache path instead of the symlinked one:

```
cd /hosted/pub.dev/agora_rtc_engine-6.6.3/windows/third_party/iris/lib
"/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/bin/cmake.exe" -E tar xzf ../iris_...zip
# exit 0
```

### Suggested fix

Resolve the source dir to its real path before using it as an extraction target:

```cmake
get_filename_component(REAL_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" REALPATH)
set(IRIS_DOWNLOAD_PATH "${REAL_SOURCE_DIR}/third_party/iris")
set(NATIVE_DOWNLOAD_PATH "${REAL_SOURCE_DIR}/third_party/native")
```

`dev/main` still extracts into `${CMAKE_CURRENT_SOURCE_DIR}` with no `REALPATH`, so the next release would carry this too.

### Two smaller things in `download_and_extract`, while you're in there

**The extraction result isn't checked.** `execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzf ...)` has no `RESULT_VARIABLE`, so a failed extraction is silent and only surfaces later as "Failed to find include directory and library directory of Iris SDK" — which points at the wrong thing and made this take a while to track down. A `RESULT_VARIABLE` plus a `FATAL_ERROR` naming the real cause would save others that detour.

**A failed extraction destroys the previous good one.** The function does `file(REMOVE_RECURSE "${EXTRACTED_DIR}")` before every extraction, with no skip-if-already-present. So the first failing configure wipes a working SDK, and re-running can't recover. Skipping when the SDK is already extracted would make this non-destructive and speed up configures generally.

### Workaround for anyone hitting this

Extract both SDKs manually into the real pub-cache paths, then create the marker `DownloadSDK.cmake` already checks so it stops re-extracting:

```
/hosted/pub.dev/agora_rtc_engine-6.6.3/windows/.plugin_dev
```

That survives `flutter clean`, but has to be redone per agora version and per machine. Pinning to VS 2022 also avoids it entirely.

### Context

This isn't specific to agora — it's caught several Flutter plugins that download and extract an SDK into their own source tree (flutter_webrtc, ffmpeg_kit_flutter, audiotags among them), all for the same reason. The `REALPATH` approach is the fix that's worked for the others. As VS 2026 adoption grows this will hit more Windows users, since Flutter's `-latest` query prefers it automatically once installed.

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.