fix(windows): extract mdk-sdk via realpath to avoid CMake symlink rejection#367
Conversation
…ection
On Flutter Windows, CMAKE_CURRENT_SOURCE_DIR is reached through the generated
plugin symlink (.../flutter/ephemeral/.plugin_symlinks/fvp). Newer CMake's
`cmake -E tar` extracts with ARCHIVE_EXTRACT_SECURE_SYMLINKS and refuses to
write entries through that symlinked directory:
CMake Error: Problem with archive_write_header():
Cannot extract through symlink ...\.plugin_symlinks\fvp
Failed to extract mdk-sdk.
Resolve CMAKE_CURRENT_SOURCE_DIR to its real (non-symlinked) path with
get_filename_component(... REALPATH) and use it as the tar WORKING_DIRECTORY,
so extraction no longer traverses the symlink. REALPATH (not file(REAL_PATH))
keeps this compatible with cmake_minimum_required(VERSION 3.17).
There was a problem hiding this comment.
Code Review
This pull request resolves the real path of CMAKE_CURRENT_SOURCE_DIR to prevent extraction failures on Flutter Windows, where the directory is accessed via a symlink and newer CMake versions refuse to extract through symlinks. The feedback recommends wrapping the path variables in double quotes within the execute_process command to avoid build failures when paths contain spaces.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| execute_process( | ||
| COMMAND ${CMAKE_COMMAND} -E tar "xvf" ${MDK_SDK_SAVE} # "--format=7zip" | ||
| WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
| WORKING_DIRECTORY ${MDK_SDK_EXTRACT_DIR} | ||
| OUTPUT_STRIP_TRAILING_WHITESPACE | ||
| RESULT_VARIABLE EXTRACT_RET | ||
| ) |
There was a problem hiding this comment.
To prevent potential build failures when the project path or the build directory contains spaces (which is common on Windows, e.g., under C:\Program Files or user directories with spaces), it is highly recommended to wrap ${MDK_SDK_SAVE} and ${MDK_SDK_EXTRACT_DIR} in double quotes within the execute_process command.
execute_process(
COMMAND ${CMAKE_COMMAND} -E tar "xvf" "${MDK_SDK_SAVE}" # "--format=7zip"
WORKING_DIRECTORY "${MDK_SDK_EXTRACT_DIR}"
OUTPUT_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE EXTRACT_RET
)
Per review (paths with spaces): quote MDK_SDK_SAVE and the resolved WORKING_DIRECTORY so extraction doesn't break on paths containing spaces.
Fixes #366.
Problem
flutter build windows --releasefails infvp_setup_depswhile extractingmdk-sdk-windows-x64.7z:On Flutter Windows,
CMAKE_CURRENT_SOURCE_DIRis reached through the generated plugin symlink (.plugin_symlinks/fvp). Newer CMake'scmake -E tarextracts withARCHIVE_EXTRACT_SECURE_SYMLINKSand refuses to write entries through a symlinked directory. The download itself is fine (verified: byte-identical 7z, valid magic) — only the extraction step is rejected. This started when CI runner images bumped their bundled CMake (≥ 3.31), with no project change.Fix
Resolve
CMAKE_CURRENT_SOURCE_DIRto its real (non-symlinked) path and extract there:get_filename_component(... REALPATH)is used instead offile(REAL_PATH)to stay compatible with the plugin'scmake_minimum_required(VERSION 3.17). On platforms where the path is not a symlink, REALPATH is a no-op (resolves to the same directory), so behavior is unchanged elsewhere. The subsequentinclude(${CMAKE_CURRENT_SOURCE_DIR}/mdk-sdk/.../FindMDK.cmake)still resolves through the symlink (reading through a symlink is fine).Verification
Built the
example/app onwindows-latest(same runner image that fails today, same plugin-symlink scenario, same mdk-sdk download). It now extracts and builds successfully:(no
Cannot extract through symlink.)