8

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?

czr_RR
  • 541
  • 5
  • 16

4 Answers4

10

/usr/bin is protected by Apple's SIP (System Integrity Protection) mechanism. You can install clickhouse into specific (not protected) directory by passing --binary-path flag. This way you won't have to disable SIP.

For example, on MacOS you can install into /usr/local/bin, which is not protected, by using this command: sudo ./clickhouse install --binary-path /usr/local/bin/.

Seer.The
  • 475
  • 5
  • 15
  • if you use this solution, since `sudo clickhouse start` (to start the clickhouse server) [assumes](https://github.com/ClickHouse/ClickHouse/blob/master/programs/install/Install.cpp#L218) your clickhouse binary is in /usr/bin, you'll need to use `sudo clickhouse start --binary-path=/usr/local/bin` when running that command (or set an alias for clickhouse server: `alias clickhouse-server="/usr/local/bin/clickhouse-server"`) – Wannabe Feb 17 '23 at 04:45
0

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;

taigetco
  • 560
  • 3
  • 13
0

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

Chujun Song
  • 138
  • 2
  • 9
-2

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
user1179442
  • 473
  • 5
  • 16