UX: improved message if CMAKE_BINARY_DIR not writeable
If the top-level binary directory is not writeable, CMake emits an error that is accurate, but could better hint to users what is going wrong. The code for the message is at https://gitlab.kitware.com/cmake/cmake/-/blob/master/Source/cmake.cxx#L2301
This becomes more relevant with CMake presets, which if binaryDir
is specified, the user is less likely to understand the error.
Perhaps the message could say the original message, but add something like:
CMake binary directory is not writeable. Please specify a writeable directory like
cmake -B ./build
or if using CMakePresets.json, check that "binaryDir" expands to a writeable directory.
cmake -B/
CMake Error: Unable to (re)create the private pkgRedirects directory:
//CMakeFiles/pkgRedirects
Suppose the following CMakeLists.txt and CMakePresets.json.
Suppose the $env{nobody}
is an environment variable that is supposed to be set e.g. $env{TMPDIR}
, but is unexpectedly not set--for example on a CI like GitHub Actions or on a user's Windows machine and the developer uses Linux/macOS and forgot that Windows doesn't set TMPDIR.
cmake_minimum_required(VERSION 3.21)
project(d LANGUAGES NONE)
{
"version": 3,
"configurePresets": [
{
"name": "default",
"binaryDir": "$env{nobody}/build/default"
}
]
}
cmake --preset default
CMake Error: Unable to (re)create the private pkgRedirects directory:
/build/default/CMakeFiles/pkgRedirects