ExternalProject_Add configure permission denied

I’m trying to build a library which depends on other libraries built via ExternalProject_Add as well which have built successfully, but for this particular project, in the configure step I receive a “Permission denied” error even though my build directory has full rwx permissions and have built and installed other libraries in the same directory. Here’s a sample of the command that seems to be causing this error

This happens with CMake version 3.24.3

    ExternalProject_Add(plumbing_ros
    BUILD_ALWAYS ON
    DOWNLOAD_COMMAND ""
    CMAKE_COMMAND ${cmake_with_env} -DCMAKE_BUILD_TYPE=RELEASE 
    BUILD_COMMAND ${cmake_with_env} --build .
    SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/plumbing"
    INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/plumbing_ros
    CMAKE_ARGS
    ${android_cmake_args}
    -DBoost_INCLUDE_DIR=${Boost_INCLUDE_DIR}
    -DBoost_LIBRARY_DIR=${Boost_LIBRARY_DIR}
    -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/plumbing_ros
    )

Are you sure it is during the configure step and not at the point where it is making directories? There’s a mkdir step that occurs before all other steps. It makes all directories needed by any of the steps. I think I’ve seen one case in the past where a directory couldn’t be created because of ownership permissions.

According to the make command once generated, I receive the following error:

[  3%] Performing configure step for 'plumbing_ros'
Permission denied
make[2]: *** [CMakeFiles/plumbing_ros.dir/build.make:107: plumbing_ros-prefix/src/plumbing_ros-stamp/plumbing_ros-configure] Error 1
make[1]: *** [CMakeFiles/Makefile2:148: CMakeFiles/plumbing_ros.dir/all] Error 2
make: *** [Makefile:141: all] Error 2

Check the command it is trying to run. Is the executable a script or binary that lacks the executable permission? It looks like you are using your own manual wrapper around running CMake, so maybe that wrapper script isn’t executable.

I made sure to assign full permissions to the entire build directory

chmod 777 -R build

but still encounter the issue

This sounds like something for strace to get more details about what, exactly, is the problem. If you have AppArmor or SELinux on the build machine, they may also limit you in different ways (e.g., not letting you build in /tmp or something).

So after running strace on the make command (with verbosity), I get the following output and still don’t see the reason why I’m getting the error

[ 29%] Performing configure step for 'plumbing_ros'
[pid 19858] +++ exited with 0 +++
[pid 19857] --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=19858, si_uid=0, si_status=0, si_utime=0, si_stime=0} ---
[pid 19857] +++ exited with 0 +++
cd /root/workspace/hyprdsp/build/plumbing_ros-prefix/src/plumbing_ros-build && /root/cmake-3.25.0-linux-x86_64/bin/cmake -E env PYTHONPATH=/root/workspace/hyprdsp/build/multisensor_framework-prefix/src/multisensor_framework-build/ros2-android-prefix/src/ros2-android-build/deps/_python_ AMENT_PREFIX_PATH=/root/workspace/hyprdsp/build/multisensor_framework-prefix/src/multisensor_framework-build/ros2-android-prefix/src/ros2-android-build/deps/ CMAKE_FIND_ROOT_PATH=/root/workspace/hyprdsp/build/multisensor_framework-prefix/src/multisensor_framework-build/ros2-android-prefix/src/ros2-android-build/deps /root/workspace/hyprdsp/build/multisensor_framework-prefix/src/multisensor_framework-build/sensor_network_interfaces /root/cmake-3.25.0-linux-x86_64/bin/cmake -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_TOOLCHAIN_FILE=/root/android-ndk-r25b/build/cmake/android.toolchain.cmake -DANDROID_ABI=arm64-v8a -DANDROID_PLATFORM=31 -DBoost_INCLUDE_DIR=/root/boost_1_80_0 -DBoost_LIBRARY_DIR=/root/boost_1_80_0/stage/lib -DCMAKE_INSTALL_PREFIX=/root/workspace/hyprdsp/build/plumbing_ros "-GUnix Makefiles" /root/workspace/hyprdsp/plumbing
strace: Process 19859 attached
[pid 19859] execve("/bin/sh", ["/bin/sh", "-c", "cd /root/workspace/hyprdsp/build"...], 0x562babc26ab0 /* 34 vars */) = 0
strace: Process 19860 attached
[pid 19860] execve("/root/cmake-3.25.0-linux-x86_64/bin/cmake", ["/root/cmake-3.25.0-linux-x86_64/"..., "-E", "env", "PYTHONPATH=/root/workspace/hyprd"..., "AMENT_PREFIX_PATH=/root/workspac"..., "CMAKE_FIND_ROOT_PATH=/root/works"..., "/root/workspace/hyprdsp/build/mu"..., "/root/cmake-3.25.0-linux-x86_64/"..., "-DCMAKE_BUILD_TYPE=RELEASE", "-DCMAKE_TOOLCHAIN_FILE=/root/and"..., "-DANDROID_ABI=arm64-v8a", "-DANDROID_PLATFORM=31", "-DBoost_INCLUDE_DIR=/root/boost_"..., "-DBoost_LIBRARY_DIR=/root/boost_"..., "-DCMAKE_INSTALL_PREFIX=/root/wor"..., "-GUnix Makefiles", "/root/workspace/hyprdsp/plumbing"], 0x5627148d70e8 /* 34 vars */) = 0
strace: Process 19861 attached
[pid 19861] execve("/root/workspace/hyprdsp/build/multisensor_framework-prefix/src/multisensor_framework-build/sensor_network_interfaces", ["/root/workspace/hyprdsp/build/mu"..., "/root/cmake-3.25.0-linux-x86_64/"..., "-DCMAKE_BUILD_TYPE=RELEASE", "-DCMAKE_TOOLCHAIN_FILE=/root/and"..., "-DANDROID_ABI=arm64-v8a", "-DANDROID_PLATFORM=31", "-DBoost_INCLUDE_DIR=/root/boost_"..., "-DBoost_LIBRARY_DIR=/root/boost_"..., "-DCMAKE_INSTALL_PREFIX=/root/wor"..., "-GUnix Makefiles", "/root/workspace/hyprdsp/plumbing"], 0x213c060 /* 37 vars */) = -1 EACCES (Permission denied)
[pid 19861] +++ exited with 1 +++
[pid 19860] --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=19861, si_uid=0, si_status=1, si_utime=0, si_stime=0} ---
Permission denied
[pid 19860] +++ exited with 1 +++
[pid 19859] --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=19860, si_uid=0, si_status=1, si_utime=0, si_stime=1} ---
[pid 19859] +++ exited with 1 +++
make[2]: *** [CMakeFiles/plumbing_ros.dir/build.make:91: plumbing_ros-prefix/src/plumbing_ros-stamp/plumbing_ros-configure] Error 1
make[2]: Leaving directory '/root/workspace/hyprdsp/build'
[pid 19856] +++ exited with 2 +++
make[1]: *** [CMakeFiles/Makefile2:172: CMakeFiles/plumbing_ros.dir/all] Error 2
make[1]: Leaving directory '/root/workspace/hyprdsp/build'
[pid 17426] +++ exited with 2 +++
make: *** [Makefile:146: all] Error 2
+++ exited with 2 +++

Running with -s 10000 will stop string truncation. You might then be able to run the command(s) directly under strace to get better output. Alternatively, -f will trace children too, but it’ll be a lot of output.

Without string truncation, I get the following output:

[ 29%] Performing configure step for 'plumbing_ros'
[pid 27602] +++ exited with 0 +++
[pid 27601] --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=27602, si_uid=0, si_status=0, si_utime=0, si_stime=0} ---
[pid 27601] +++ exited with 0 +++
cd /root/workspace/hyprdsp/build/plumbing_ros-prefix/src/plumbing_ros-build && /root/cmake-3.25.0-linux-x86_64/bin/cmake -E env PYTHONPATH=/root/workspace/hyprdsp/build/multisensor_framework-prefix/src/multisensor_framework-build/ros2-android-prefix/src/ros2-android-build/deps/_python_ AMENT_PREFIX_PATH=/root/workspace/hyprdsp/build/multisensor_framework-prefix/src/multisensor_framework-build/ros2-android-prefix/src/ros2-android-build/deps/ CMAKE_FIND_ROOT_PATH=/root/workspace/hyprdsp/build/multisensor_framework-prefix/src/multisensor_framework-build/ros2-android-prefix/src/ros2-android-build/deps /root/workspace/hyprdsp/build/multisensor_framework-prefix/src/multisensor_framework-build/sensor_network_interfaces /root/cmake-3.25.0-linux-x86_64/bin/cmake -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_TOOLCHAIN_FILE=/root/android-ndk-r25b/build/cmake/android.toolchain.cmake -DANDROID_ABI=arm64-v8a -DANDROID_PLATFORM=31 -DBoost_INCLUDE_DIR=/root/boost_1_80_0 -DBoost_LIBRARY_DIR=/root/boost_1_80_0/stage/lib -DCMAKE_INSTALL_PREFIX=/root/workspace/hyprdsp/build/plumbing_ros "-GUnix Makefiles" /root/workspace/hyprdsp/plumbing
strace: Process 27603 attached
[pid 27603] execve("/bin/sh", ["/bin/sh", "-c", "cd /root/workspace/hyprdsp/build/plumbing_ros-prefix/src/plumbing_ros-build && /root/cmake-3.25.0-linux-x86_64/bin/cmake -E env PYTHONPATH=/root/workspace/hyprdsp/build/multisensor_framework-prefix/src/multisensor_framework-build/ros2-android-prefix/src/ros2-android-build/deps/_python_ AMENT_PREFIX_PATH=/root/workspace/hyprdsp/build/multisensor_framework-prefix/src/multisensor_framework-build/ros2-android-prefix/src/ros2-android-build/deps/ CMAKE_FIND_ROOT_PATH=/root/workspace/hyprdsp/build/multisensor_framework-prefix/src/multisensor_framework-build/ros2-android-prefix/src/ros2-android-build/deps /root/workspace/hyprdsp/build/multisensor_framework-prefix/src/multisensor_framework-build/sensor_network_interfaces /root/cmake-3.25.0-linux-x86_64/bin/cmake -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_TOOLCHAIN_FILE=/root/android-ndk-r25b/build/cmake/android.toolchain.cmake -DANDROID_ABI=arm64-v8a -DANDROID_PLATFORM=31 -DBoost_INCLUDE_DIR=/root/boost_1_80_0 -DBoost_LIBRARY_DIR=/root/boost_1_80_0/stage/lib -DCMAKE_INSTALL_PREFIX=/root/workspace/hyprdsp/build/plumbing_ros \"-GUnix Makefiles\" /root/workspace/hyprdsp/plumbing"], 0x55902d281ab0 /* 34 vars */) = 0
strace: Process 27604 attached
[pid 27604] execve("/root/cmake-3.25.0-linux-x86_64/bin/cmake", ["/root/cmake-3.25.0-linux-x86_64/bin/cmake", "-E", "env", "PYTHONPATH=/root/workspace/hyprdsp/build/multisensor_framework-prefix/src/multisensor_framework-build/ros2-android-prefix/src/ros2-android-build/deps/_python_", "AMENT_PREFIX_PATH=/root/workspace/hyprdsp/build/multisensor_framework-prefix/src/multisensor_framework-build/ros2-android-prefix/src/ros2-android-build/deps/", "CMAKE_FIND_ROOT_PATH=/root/workspace/hyprdsp/build/multisensor_framework-prefix/src/multisensor_framework-build/ros2-android-prefix/src/ros2-android-build/deps", "/root/workspace/hyprdsp/build/multisensor_framework-prefix/src/multisensor_framework-build/sensor_network_interfaces", "/root/cmake-3.25.0-linux-x86_64/bin/cmake", "-DCMAKE_BUILD_TYPE=RELEASE", "-DCMAKE_TOOLCHAIN_FILE=/root/android-ndk-r25b/build/cmake/android.toolchain.cmake", "-DANDROID_ABI=arm64-v8a", "-DANDROID_PLATFORM=31", "-DBoost_INCLUDE_DIR=/root/boost_1_80_0", "-DBoost_LIBRARY_DIR=/root/boost_1_80_0/stage/lib", "-DCMAKE_INSTALL_PREFIX=/root/workspace/hyprdsp/build/plumbing_ros", "-GUnix Makefiles", "/root/workspace/hyprdsp/plumbing"], 0x563f9263e0e8 /* 34 vars */) = 0
strace: Process 27605 attached
[pid 27605] execve("/root/workspace/hyprdsp/build/multisensor_framework-prefix/src/multisensor_framework-build/sensor_network_interfaces", ["/root/workspace/hyprdsp/build/multisensor_framework-prefix/src/multisensor_framework-build/sensor_network_interfaces", "/root/cmake-3.25.0-linux-x86_64/bin/cmake", "-DCMAKE_BUILD_TYPE=RELEASE", "-DCMAKE_TOOLCHAIN_FILE=/root/android-ndk-r25b/build/cmake/android.toolchain.cmake", "-DANDROID_ABI=arm64-v8a", "-DANDROID_PLATFORM=31", "-DBoost_INCLUDE_DIR=/root/boost_1_80_0", "-DBoost_LIBRARY_DIR=/root/boost_1_80_0/stage/lib", "-DCMAKE_INSTALL_PREFIX=/root/workspace/hyprdsp/build/plumbing_ros", "-GUnix Makefiles", "/root/workspace/hyprdsp/plumbing"], 0x234d060 /* 37 vars */) = -1 EACCES (Permission denied)
[pid 27605] +++ exited with 1 +++
[pid 27604] --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=27605, si_uid=0, si_status=1, si_utime=0, si_stime=0} ---
Permission denied
[pid 27604] +++ exited with 1 +++
[pid 27603] --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=27604, si_uid=0, si_status=1, si_utime=0, si_stime=2} ---
[pid 27603] +++ exited with 1 +++
make[2]: *** [CMakeFiles/plumbing_ros.dir/build.make:91: plumbing_ros-prefix/src/plumbing_ros-stamp/plumbing_ros-configure] Error 1
make[2]: Leaving directory '/root/workspace/hyprdsp/build'
[pid 27600] +++ exited with 2 +++
make[1]: *** [CMakeFiles/Makefile2:172: CMakeFiles/plumbing_ros.dir/all] Error 2
make[1]: Leaving directory '/root/workspace/hyprdsp/build'
[pid 25105] +++ exited with 2 +++
make: *** [Makefile:146: all] Error 2
+++ exited with 2 +++

The sensor_network_interfaces from build dir is used as wrapper for the CMake call, and that one most probably causes the error message.
Was this on purpose or is ${cmake_with_env} incorrectly defined?

${cmake_with_env} is defined as:

set(cmake_with_env "${CMAKE_COMMAND}" -E
  env
  "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}/ros2-android-prefix/src/ros2-android-build/deps/_python_"
  "AMENT_PREFIX_PATH=${CMAKE_CURRENT_BINARY_DIR}/ros2-android-prefix/src/ros2-android-build/deps"
  "${CMAKE_COMMAND}")

If you look at the second execve, you can see that between the AMENT_PREFIX_PATH and the 'cmake` executable there is an additional:

CMAKE_FIND_ROOT_PATH=/root/workspace/hyprdsp/build/multisensor_framework-prefix/src/multisensor_framework-build/ros2-android-prefix/src/ros2-android-build/deps /root/workspace/hyprdsp/build/multisensor_framework-prefix/src/multisensor_framework-build/sensor_network_interfaces

I don’t know where that comes from, but I assume the second path should have been defined as part of CMAKE_FIND_ROOT_PATH separated by semicolon.
And not as separate argument to the call, that’s why it was used as executable in front of the cmake call (see the 3rd execve).

Okay, I believe I resolved this particular issue by updating the CMake command the way I submitted in this ticket, but still encounter that relevant issue