Unable to install ClickHouse in MacOS due to CANNOT_OPEN_FILE - clickhouse

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?

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

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:
Restart the computer and press command+R until the Apple logo appears. At this time, you will enter Recovery Mode.
After selecting a language, enter recovery mode, find Utilities in the above menu, and find Terminal in it;
Open the terminal and enter the following command to close SIP;

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

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

Related

Advice on how to delete a software on OSX

I have a software installed on my OSX computer that affects my daily work so I decide to remove it.
The OSX version is 10.14.3.
I have disabled System Integrity Protection (rootless).
It has a continuous running daemon set up in launchctl.
When I try to run the command "sudo launchctl remove "deamon'name"" to disable the running daemon, I got
sudo: unable to execute /bin/launchctl: Operation not permitted
Of course, remove the files for this software using "sudo rm -rf" failed with "Permission denied"
So how can I remove this software without reinstalling OS?

Run a C++ program in Clion as root

I'm trying to run a program written in C++ by using CLion v1.2 as super user. Anyone here knows how to run it as superuser? I'm using CMake.
I solved this by remote debugging on local machine. I run gdbserver with root privileges and connected to it from CLion.
To start gdbserver sudo gdbserver :port myapp, configure remote GDB debug with port
This was already implemented on CLion, starting 2020.3:
https://www.jetbrains.com/help/clion/debug-as-root.html
If you are asking to run the debugger as sudo/administrator, I had the same issue. On Linux you can open CLion as sudo and gdb will not have root permission issues running an executable:
sudo ./clion.sh
I would guess that you could right click in Windows and "Run as administrator" to get the same result.
There is a feature request into JetBrains to run the debugger as root that could use more up voting.
A workaround is:
From https://www.jetbrains.com/help/clion/attaching-to-local-process.html#prereq-ubuntu
If you are using CLion on Ubuntu (or probably, on some other Linux distribution), upon the first attempt to attach to the local process you can get the ptrace: Operation not permitted. error message. To disable it and enable attach to the local process feature, do the following:
To disable this restriction temporarily, enter the command:
echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
To disable this restriction permanently, open the file /etc/sysctl.d/10-ptrace.conf for editing and change the line kernel.yama.ptrace_scope = 1 to kernel.yama.ptrace_scope = 0. To apply the changes, enter:
sudo service procps restart or restart your system, at your choice.
You can create a bash script to help you. For example, run.sh:
#!/usr/bin/env bash
echo $LOGIN_PASSWD | sudo -S yourExecutable --with=some-arguments
Don't forget to chmod a+x run.sh, and export the password of current account as an environment variable in Run/Debug Configurations.

wkhtmltopdf opens an application on OSX and doesn't finish its job till I focus this application

As far as I read wkhtmltopdf is using a patched version of Qt so that it can be executed WITHOUT using a graphical server such as Xorg, etc but when I run it in my OSX, it opens an application, it's visible in dock and when I press Command-Tab it's visible in list of applications shown, the icon of this app is a text "exec" in a black background. As soon as I focus this app it gets closed and wkhtmltopdf finishes its job but if I don't focus it, it doesn't finish its job at all.
Any ideas what can I do? I want it to run in background and respond automatically, I can't sit behind the system and Command-Tab each time a request is sent.
Update:
I tried it with an Ubuntu Server and it raises this error:
wkhtmltopdf: cannot connect to X server localhost:10.0
when I try to run wkhtmltopdf directly in command line. Isn't it against to whole purpose of patching Qt so that it doesn't need an X server?
It got solved after I faced the problem in Ubuntu, by searching the error raised in Ubuntu I could find this post wkhtmltopdf: cannot connect to X server which seems led me to install the package from sourceforge (both in OSX and Ubuntu) and it solved my problem (both in OSX and Ubuntu)
You must copy it into directory : /usr/local/bin, make sur it's executable and add symlink of wkhtmltopdf.sh like :
1- the command :
brew cask install wkhtmltopdf
2 - insert the binary in directory /usr/bin so the browser can't have permission to execute in this directory.
You must copy the wkhtmltopdf.sh to directory /usr/local/bin cause the browser have permission in this directory like:
sudo cp /usr/bin/wkhtmltopdf.sh /usr/local/bin/wkhtmltopdf.sh
3 - After make sur the binary have permission of execution like :
sudo chmod a+x /usr/local/bin/wkhtmltopdf.sh
4 - so now you can test, it's work like:
/usr/local/bin/wkhtmltopdf.sh http://www.google.com google.pdf
it make download the pdf in the current directory in your terminal
5 - Optional
now you can add symlink in your directory /usr/local/bin like
ln -s /usr/local/bin/wkhtmltopdf.sh /usr/local/bin/wkhtmltopdf
6 - copy to the /usr/bin/wkhtmltoimage into /usr/local/bin/wkhtmltoimage like:
sudo cp usr/local/wkhtmltoimage usr/local/bin/wkhtmltoimage
8- make sur this is executable too:
sudo chmod a+x /usr/local/bin/wkhtmltoimage
I Hope it's help you

RabbitMQ command doesn't exist?

OS: Mac OSX 10.9
I have rabbitmq installed via home brew and when I go to /usr/local/sbin and run rabbitmq-server it states that: rabbitmq-server: command not found even as sudo it states the same error.
How do I get rabbitmq to start if it's not a command? I have also tried chmod +x rabbitmq-server in that directory to get it be an executable, same issue.
From the docs:
The RabbitMQ server scripts are installed into /usr/local/sbin. This is not automatically added to your path, so you may wish to add
PATH=$PATH:/usr/local/sbin to your .bash_profile or .profile. The server can then be started with rabbitmq-server.
All scripts run under your own user account. Sudo is not required.
You should be able to run /usr/local/sbin/rabbitmq-server or add it to your path to run it anywhere.
Your command failed because, by default, . is not on your $PATH. You went to the right directory (/usr/local/sbin) and wanted to run the rabbitmq-server that existed and had exec permissions, but by typing rabbitmq-server as a command Unix only searches for that command on your $PATH directories - which didn't include /usr/local/sbin.
What you wanted to do can be achieved by typing ./rabbitmq-server - say, execute the rabbitmq-server program that is in the current directory. That's analogous to running /usr/local/sbin/rabbitmq-server from everywhere - . represents your current directory, so it's the same as /usr/local/sbin in that context.
My OS: macOS Sierra 10.12.5
My RabbitMQ was installed using:
brew install rabbitmq
And it was installed into /usr/local/Cellar, just in case if someone has same situation with me, you would need to do similarly:
In terminal:
ls /usr/local/Cellar/rabbitmq/
to check which version you have installed, and then add to .bash_profile:
export PATH=/usr/local/Cellar/rabbitmq/<version>/sbin:$PATH
On mac by this command you can start,restart or stop rabbitmq
brew services start rabbitmq
brew services stop rabbitmq
brew services restart rabbitmq
As rabbitmq-server resides in /usr/local/sbin, running this command will enable starting server from anywhere:
export PATH=/usr/local/sbin:$PATH
I installed using home brew and I did the following:
brew install rabbitmq.
encountered issues cause the installation happened under bin and not /usr/local/sbin
So I did the following:
1. chown -R `whoami`:admin /usr/local/sbin
2. chown -R `whoami`:admin /usr/local/share
3. brew install rabbitmq
4. /usr/local/sbin/rabbitmq-server
And then the server runs and you can login to the management console :
http://localhost:15672/
userame: guest
password: guest
Start the service like this:
brew services start rabbitmq
Or if you don't need to start it as service:
/usr/local/sbin/rabbitmq-server
In my case the paths /usr/local/sbin/ nor /usr/local/Cellar/rabbitmq/ etc., did not work as Homebrew was putting these all together in a different location.
I opened Finder in my Mac and searched for rabbitmq-server in the search textbox on top right corner of the Finder window.
rabbitmq-server was located under the path below:
/Users/${USER}/homebrew/Cellar/rabbitmq/3.7.15/sbin
So in my ~/.bash_profile , I updated the PATH as below:
export PATH=$PATH:/Users/${USER}/homebrew/Cellar/rabbitmq/3.7.15/sbin
After source ~/.bash_profile
~ $ rabbitmq-server
## ##
## ## RabbitMQ 3.7.15. Copyright (C) 2007-2019 Pivotal Software, Inc.
########## Licensed under the MPL. See https://www.rabbitmq.com/
###### ##
########## Logs: /Users/santoshsindham/homebrew/var/log/rabbitmq/rabbit#localhost.log
/Users/santoshsindham/homebrew/var/log/rabbitmq/rabbit#localhost_upgrade.log
Starting broker...
completed with 6 plugins.
Just add this in your ~/.bash_profile
export PATH=$PATH:/usr/local/opt/rabbitmq/sbin
I installed using HomeBrew I added this to my bash profile
PATH=$PATH:/usr/local/Cellar
This worked for me
I have Mac OS version 10.13.6 installed. Somehow I did not have sbin directory present under /usr/local/. On carefully looking I found that for me the rabbitmq-server binary was present here /usr/local/Cellar/rabbitmq/3.7.9/sbin/rabbitmq-server.
i have read a wonderful article to fix that
simply open your bash_profile or .profile.
sudo nano ./bash_profile
in the begin of the file add PATH=$PATH:/usr/local/sbin, close and save, then write source ~/.bash_profile and lastly restart your terminal.
problem fix it!
http://www.andrewcranston.me/en/engineering/rabbitmq-and-path-variable/

connect failed mongo db on mac osx

i'm trying to learn mongo db on my mac. I installed mondgo db using homebrew and it appeard successful. I created the dir /data/db. when I type mongo into the terminal I get:
Error: couldn't connect to server [a bunch of numbers] at src/mongo/shell/mongo.js:145 exception:connect failed
I looked at the following answer on SO: Installing and Running MongoDB on OSX
in the check answer it says:
1) Start a terminal for your mongo server
2)Go to mongo/bin directory
What does it mean to start a terminal for your server? does that mean just open up a new terminal window?
Where can I find the mongo/bin directory?
Any other suggestions on getting mondoDB up and running would be appreciated.
you should read the documentation here: http://docs.mongodb.org/manual/tutorial/install-mongodb-on-os-x/
And follow the instructions.
In this case the [bunch of numbers] are the hostname/ip and port number that the binary mongo has tried to connect to. What it's telling you is that there is no mongod binary listening on the hostname and port that mongo is trying to connect to.
You will need to start mongod before you are able to connect to it with a mongo shell. The documentation above outlines this further.
If you use homebrew the mongodb binaries will automatically be put on your path which means you won't need to cd into another directory like mongo/bin.
Good luck.
Probably you run the mongodb first time. Based on the documentation you must follow a few steps and then you are ready to go.
First, create main db directory:
sudo mkdir -p /data/db
Make sure that you have a read and write permission on that directory:
sudo chown `id -u` /data/db
And to listen to default port, run:
mongod
Finally keep in mind that after the run "mongod" command do not close console tab. Open a new tab (Cmd + T) and run other commands on the new window. To close the mongod session simply hit the Ctrl + C on the previous tab.
when everything mentioned above did not work. I did the following thing (in Mac)
cd ~
mkdir -p data/db
After creating directory in home(which will be definitely allowed) most imp command is below
mongod --dbpath ~/data/db &
So that it could take the path of db which was in home directory (as we are not able to create in / dir.
To avoid it running frequently, put the above command in .bash_profile file in home directory so that it will automatically run the above command whenever we try to use terminal in Mac
Note: Whenever we open the terminal it will execute the above command so that we can access the mongodb (I understand this should be taken place in background but it works fine)
We need to press enter/return key to get the regular command line terminal and continue doing our work
These steps worked for me well on Mac, you can give a shot, make sure you install brew first and put these lines in terminal line by line:
brew update
brew install mongodb
brew install mongodb --with-openssl
brew install mongodb --devel
sudo mkdir -p /data/db
sudo chown -R [your username] /data/db
(Replace with your username with what you can get by typing whoami in the terminal)
mongod
Run you app, for example localhost:8000

Resources