CMake fails on external drive

I am trying to run CMake to generate VS2017 solutions from source folder(with pre-defined CMakeList files). It works fine if the output folder is on C drive(I only have one drive in this Windows 11). If I change the output folder to any folder in the external drive(portable drive), then it will fail with the following errors:

CMake Error at CMakeLists.txt:35 (project):
No CMAKE_C_COMPILER could be found

CMake Error at CMakeLists.txt:35 (project):
No CMAKE_CXX_COMPILER could be found.

I know this is not correct and complier is fine, but it did fail every time like this. Have no idea why. Update from 3.28 to latest 3.29.4, still same problem.

Any help? Is this a bug or some setting is not correct?

In general there could be an issue of say virus scanner or permissions issue. It would be helpful to see CMakeConfigureLog.yml from CMAKE_BINARY_DIR/CMakeFiles/

Please reduce your project down to a minimal CMakeLists.txt that still reproduces your problem, and provide a set of steps to follow so that someone else can replicate the issue. The problem is likely in the details of those.