czr_RR
czr_RR

Reputation: 591

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?

Upvotes: 8

Views: 5090

Answers (4)

Seer.The
Seer.The

Reputation: 486

/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/.

Upvotes: 10

Chujun Song
Chujun Song

Reputation: 158

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

Upvotes: 0

taigetco
taigetco

Reputation: 570

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;

Upvotes: 0

user1179442
user1179442

Reputation: 483

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

Upvotes: -2

Related Questions