oswaldo
oswaldo

Reputation: 23

CMake Error : file INSTALL cannot set permissions on "/usr/local/include": Operation not permitted

I'm trying to run a transpiler project that converts alfa code to a solidity smart contracts, but after i run the final command make in order to generate an executable that'll convert the alfa to solidity, i get the following error:

CMake Error at _deps/googletest-build/googlemock/cmake_install.cmake:46 (file):
  file INSTALL cannot set permissions on "/usr/local/include": Operation not
  permitted.
Call Stack (most recent call first):
  _deps/googletest-build/cmake_install.cmake:47 (include)
  runtime/cmake_install.cmake:47 (include)
  cmake_install.cmake:47 (include)

although i have set the permissions on /usr/local/include to 777, i still get the error after running the command.

I tried running sudo make instead of make but then i get other errors related to the antlr4-runtime library, which is this, but it has no answers : some includes are broken after antlr4 c++ runtime setup on linux.

Any help is appreciated, thank you.

here is the full trace of the error:

Consolidate compiler generated dependencies of target antlr4_tests
make[5]: Leaving directory '/home/ubuntu/new/transpiler/build6/antlr4cpp-prefix/src/antlr4cpp-build'
make  -f runtime/CMakeFiles/antlr4_tests.dir/build.make runtime/CMakeFiles/antlr4_tests.dir/build
make[5]: Entering directory '/home/ubuntu/new/transpiler/build6/antlr4cpp-prefix/src/antlr4cpp-build'
make[5]: Nothing to be done for '_deps/googletest-build/googlemock/CMakeFiles/gmock_main.dir/build'.
make[5]: Leaving directory '/home/ubuntu/new/transpiler/build6/antlr4cpp-prefix/src/antlr4cpp-build'
make[5]: Entering directory '/home/ubuntu/new/transpiler/build6/antlr4cpp-prefix/src/antlr4cpp-build'
make[5]: Nothing to be done for 'runtime/CMakeFiles/antlr4_tests.dir/build'.
make[5]: Leaving directory '/home/ubuntu/new/transpiler/build6/antlr4cpp-prefix/src/antlr4cpp-build'
[ 99%] Built target gmock_main
[100%] Built target antlr4_tests
make[4]: Leaving directory '/home/ubuntu/new/transpiler/build6/antlr4cpp-prefix/src/antlr4cpp-build'
/usr/bin/cmake -E cmake_progress_start /home/ubuntu/new/transpiler/build6/antlr4cpp-prefix/src/antlr4cpp-build/CMakeFiles 0
make  -f CMakeFiles/Makefile2 preinstall
make[4]: Entering directory '/home/ubuntu/new/transpiler/build6/antlr4cpp-prefix/src/antlr4cpp-build'
make[4]: Nothing to be done for 'preinstall'.
make[4]: Leaving directory '/home/ubuntu/new/transpiler/build6/antlr4cpp-prefix/src/antlr4cpp-build'
Install the project...
/usr/bin/cmake -P cmake_install.cmake
-- Install configuration: "Release"
-- Up-to-date: /usr/local/include
CMake Error at _deps/googletest-build/googlemock/cmake_install.cmake:46 (file):
  file INSTALL cannot set permissions on "/usr/local/include": Operation not
  permitted.
Call Stack (most recent call first):
  _deps/googletest-build/cmake_install.cmake:47 (include)
  runtime/cmake_install.cmake:47 (include)
  cmake_install.cmake:47 (include)


make[3]: *** [Makefile:130: install] Error 1
make[3]: Leaving directory '/home/ubuntu/new/transpiler/build6/antlr4cpp-prefix/src/antlr4cpp-build'
make[2]: *** [CMakeFiles/antlr4cpp.dir/build.make:102: antlr4cpp-prefix/src/antlr4cpp-stamp/antlr4cpp-install] Error 2
make[2]: Leaving directory '/home/ubuntu/new/transpiler/build6'
make[1]: *** [CMakeFiles/Makefile2:86: CMakeFiles/antlr4cpp.dir/all] Error 2
make[1]: Leaving directory '/home/ubuntu/new/transpiler/build6'
make: *** [Makefile:91: all] Error 2

Upvotes: 0

Views: 9515

Answers (3)

lydia
lydia

Reputation: 1

it seems a cmake feature ,when installing a directory cmake tries to set permissions on it even when the directory existed before running cmake. Why not skip setting permissions on existing directories?

Upvotes: 0

Ilya Kremniou
Ilya Kremniou

Reputation: 39

I faced similar issue when I tried to install the CMake project that utilizes GoogleTest library. The library has a check whether to install its binaries or not. See here.

It looks like that when antlr4-runtime is installed by the GNU make it triggeres the installtion of the GoogleTest, however this is not required in your case. You have the following options:

  1. For anyone facing this issue with CMake projects can find two workarounds in this github issue
    • add option(INSTALL_GTEST OFF) before FetchContent_MakeAvailable(googletest)
    • if add_subdirectory(googletest) is used instead, pass EXCLUDE_FROM_ALL to prevent installation.
  2. Propagate the INSTALL_GTEST=OFF to the CMake using the -D option. cmake -DINSTALL_GTEST=OFF

Upvotes: 1

MadScientist
MadScientist

Reputation: 100956

The error is that it wants to set the permissions of /usr/local/include itself, not add content to /usr/local/include. It doesn't matter what permissions you've given, only the owner of a file (or directory) can change the permissions of that file (or directory).

Upvotes: 1

Related Questions