'Unable to install ClickHouse in MacOS due to CANNOT_OPEN_FILE

While trying to install ClickHouse in a macOS Catalina, doing the following command:

➜ ~ curl -O 'https://builds.clickhouse.tech/master/macos/clickhouse' && chmod a+x ./clickhouse

After trying to execute sudo ./clickhouse install it will complain with the following message:

Copying ClickHouse binary to /usr/bin/clickhouse.new
Code: 76. DB::ErrnoException: Cannot open file /usr/bin/clickhouse.new, errno: 1, strerror: Operation not permitted. (CANNOT_OPEN_FILE) (version 21.10.1.7886 (official build))

Why is it failing even if I sudo the command? Are there any other commands required before trying to install ClickHouse?



Solution 1:[1]

This is a rootless (SIP) mechanism that Apple has added to the new version of the system. The basic purpose of SIP is to prevent programs from obtaining root privileges and modifying several key system directories. It can indeed play a certain protective role. The main directories to be protected are:

  • /System
  • /usr
  • /bin
  • /sbin and preinstalled apps

Close the SIp in the kernel:

  1. Restart the computer and press command+R until the Apple logo appears. At this time, you will enter Recovery Mode.

  2. After selecting a language, enter recovery mode, find Utilities in the above menu, and find Terminal in it;

  3. Open the terminal and enter the following command to close SIP;

Solution 2:[2]

You can bypass the problem by installing ClickHouse this way here: https://clickhouse.com/docs/en/quick-start/#1-start-clickhouse.

Solution 3:[3]

Try to use docker to install clickhouse server/client.

docker pull yandex/clickhouse-server
docker pull yandex/clickhouse-client
docker run -it --rm --link some-clickhouse-server:clickhouse-server yandex/clickhouse-client --host clickhouse-server

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 taigetco
Solution 2 Chujun Song
Solution 3 user1179442