I am getting an error when compiling Slicer on Ubu22.04 (from git master, cloned on Jan24) but it is a bit cryptic. Could you let me know what could be happening?
After 3 hours of building, it ends with:
-- Setting CPACK_PACKAGE_NAME to 'Slicer'
-- Setting CPACK_PACKAGE_VENDOR to 'slicer.org'
-- Setting CPACK_PACKAGE_VERSION_MAJOR to '5'
-- Setting CPACK_PACKAGE_VERSION_MINOR to '9'
-- Setting CPACK_PACKAGE_VERSION_PATCH to '0'
-- Setting CPACK_PACKAGE_VERSION to '5.9.0-2025-01-28'
-- Setting CPACK_PACKAGE_INSTALL_DIRECTORY to 'Slicer 5.9.0-2025-01-28'
-- Setting CPACK_PACKAGE_DESCRIPTION_FILE to '/opt/Slicer_src/README.md'
-- Setting CPACK_RESOURCE_FILE_LICENSE to '/opt/Slicer_src/License.txt'
-- Setting CPACK_PACKAGE_DESCRIPTION_SUMMARY to 'Medical Visualization and Processing Environment for Research'
-- Configuring incomplete, errors occurred!
make[2]: *** [CMakeFiles/Slicer.dir/build.make:127: Slicer-prefix/src/Slicer-stamp/Slicer-configure] Error 1
make[1]: *** [CMakeFiles/Makefile2:1826: CMakeFiles/Slicer.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
Thanks for the hint, I see this mid-wise in the build:
CMake Error: Could not open file for write in copy operation /opt/Slicer_src/Utilities/Scripts/SlicerWizard/__version__.py.tmp
CMake Error: : System Error: Permission denied
CMake Error at Utilities/Scripts/SlicerWizard/CMakeLists.txt:12 (configure_file):
configure_file Problem configuring file
It looks like you’re building the project in the /opt/ directory, which is likely owned by the root user. This is probably causing the error we’re seeing.
In this case, __version__.py needs to be configured within the source tree[1], but it’s likely not writable in your setup.
To resolve this, you can:
Build and develop from your home directory, or
Update the permissions for /opt/Slicer_src.
Unless you have a specific reason to build in /opt/, I recommend option (1).
As a suggestion, since it’s not overly common that the build dir interacts with the source dir, may I suggest the following (pseudocode) improvement in the main CMakeLists, to inform the user about the error more easily/quickly? So that error happens right away, not after x hours and in the middle of the log.
if(CMAKE_VERSION VERSION_GREATER "3.21.0")
file(COPY_FILE ${CMAKE_SOURCE_DIR}/README.md ${CMAKE_SOURCE_DIR}/Utilities/Scripts/SlicerWizard/.tmp_txt RESULT result)
if(NOT result)
message(ERROR "You need write permissions in the source dir")
endif()
endif()
I typically use /opt/s as a build directory on mac (need to create it first and change permissions with sudo). Keeping the build directory short avoids path length errors.