Quick tip: how to add hdbsql to a $PATH on MacOS
I was following that new tutorials mission Use Clients to Query an SAP HANA Database published this week by Daniel Van Leeuwen and I finally installed
hdbsql on my MacOS. I used
hdbsql on Linux and on Windows in the past, but — for whatever reason — never on Mac.
Once I was done with the standard installation I got all SAP HANA clients in the default (as of now, for the version 2.4) directory
The next step should be to add this directory to the
$PATH environment variable. Ok, the installation comes with the helpful, yet little known, bash script called
hdbclienv.sh. Once you execute…
… it will set environment variable
HDB_CLIENT_HOME and will add it to the
$PATH in your session.
But I still need to type that path, if I want to run it… So, the question remains how do I add this directory with SAP HANA Clients to my system’s
I’ve done this hundred times on Windows, where there is the central location to edit it for a current user or for all users. But what is that central location for MacOS?
Obviously, because I am using
bash right now, I can simply add this to my
bash profile. But as a developer advocate I want to think not only about my preferences, but as well about other preferences that developers in our SAP HANA community might have. As well, I know
/etc/profile is the system-wide profile, but it can be modified or overwritten by another MacOS upgrade.
After a bit of a research I finally found what I was looking for: the special location
/etc/paths.d where applications or users can add a file containing the list of directories that should be added to the
Let’s try it!
root can write to
/etc/paths.d, so I need to do something like…
sudo sh -c 'echo "/Applications/sap/hdbclient" >> /etc/paths.d/sap'
… and to open another session to check it working.
which hdbsql which hdbclienv.sh source hdbclienv.sh echo $HDB_CLIENT_HOME hdbsql
I hope those of you using MacOS will find it useful too 🙂
Stay healthy and have a good weekend,
-Vitaliy (aka @Sygyzmundovych)
Thanks great Blog! Simple, Fast and Sucess!
Worked for me, thank you
Thanks alot! Its really Helpful.
Thanks a lot! Very useful!