Mac OS Brew build INSTALL DESTINATION "/usr/local" permissions error
CreateTheImaginable opened this issue · comments
When doing a Brew build - https://github.com/vfxpro99/usd-build-club/wiki/USD-on-macOS#building-usd-on-macos-using-brew
I get a /usr/local permissions error, see below...
=== BUILD AGGREGATE TARGET install OF PROJECT usd WITH CONFIGURATION Release ===
Check dependencies
Write auxiliary files
write-file ~/Projects/stage/build/usd.build/Release/install.build/Script-B1C0B8A4926A49DCA9E02A73.sh
chmod 0755 ~/Projects/stage/build/usd.build/Release/install.build/Script-B1C0B8A4926A49DCA9E02A73.sh
PhaseScriptExecution CMake\ PostBuild\ Rules ~/Projects/stage/build/usd.build/Release/install.build/Script-B1C0B8A4926A49DCA9E02A73.sh
cd ~/Projects/USD
/bin/sh -c ~/Projects/stage/build/usd.build/Release/install.build/Script-B1C0B8A4926A49DCA9E02A73.sh
/usr/local/Cellar/cmake/3.7.2/bin/cmake -DBUILD_TYPE=Release -P cmake_install.cmake
-- Install configuration: "Release"
-- Installing: /usr/local/lib/python/pxr/init.py
-- Installing: /usr/local/share/usd/plugins/plugInfo.json
CMake Error at pxr/cmake_install.cmake:39 (file):
file cannot create directory: /usr/local/plugin/usd. Maybe need
administrative privileges.
Call Stack (most recent call first):
cmake_install.cmake:32 (include)
make: *** [install_buildpart_0] Error 1
Command /bin/sh failed with exit code 2
Looks like it is related to references to /usr/local in the ~/Projects/stage/build/pxr/cmake_install.cmake file:
if("${CMAKE_INSTALL_COMPONENT}" STREQUAL "Unspecified" OR NOT CMAKE_INSTALL_COMPONENT)
list(APPEND CMAKE_ABSOLUTE_DESTINATION_FILES
"/usr/local/pxrConfig.cmake")
if(CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION)
message(WARNING "ABSOLUTE path INSTALL DESTINATION : ${CMAKE_ABSOLUTE_DESTINATION_FILES}")
endif()
if(CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION)
message(FATAL_ERROR "ABSOLUTE path INSTALL DESTINATION forbidden (by caller): ${CMAKE_ABSOLUTE_DESTINATION_FILES}")
endif()
file(INSTALL DESTINATION "/usr/local" TYPE FILE FILES "~/Projects/stage/build/pxrConfig.cmake")
endif()
I got around this in a pretty questionable way, by chowning /usr/local and suppressing System Integrity Protection. It's probably a good idea to modify the brew build to build to a non /usr/local location. Any thoughts?
In the build-macos-brew.sh I added the line "-DCMAKE_INSTALL_PREFIX=${ROOT}/INSTALL " to cmake and that seems to give me a successful build... See below:
The installed files will show up in stage/INSTALL
cmake -G "Xcode" ../../USD \
-DCMAKE_INSTALL_PREFIX=${ROOT}/INSTALL \
-DOPENSUBDIV_ROOT_DIR=${ROOT}/homebrew \
-DCMAKE_PREFIX_PATH=${ROOT}/homebrew \
...
setting the install prefix is the right approach.