How To Add Package (like 'Rabbitmq') To Path On Mac Zsh

Have you ever been in a situation where you installed a library or package via terminal and you do not have access to the package? Or after an installation of a package , you try and check the version of the package and you receive an error that zsh command not found ? Well it happens to beginner programmers a lot.

Path is the system or environment variable that contain packages installed unto the computer and makes you not to specify full path for those packages when needed. So to make this tutorial practical, we will be adding rabbitmq to our PATH.

First of all install rabbitmq via brew:

  • brew update && brew upgrade
    
  • brew install rabbitmq
    
  • Then run rabbitmq-server to launch Rabbitmq

You will receive this prompt if sbin is not in the PATH:

Screenshot 2022-02-11 at 22.00.55.png

This is because RabbitMQ server scripts and CLI tools are installed into the sbin directory and normally sbin is not specified in PATH. You can check to see if '/usr/local/sbin' is in PATH by this command:

echo $PATH

Here is what my PATH contains:

Screenshot 2022-02-11 at 21.52.35.png

As you can see there is not '/usr/local/sbin' in the list above.

So to add 'sbin' or '/usr/local/sbin' to PATH, type this command:

export PATH=$PATH:/usr/local/sbin

Then confirm by displaying the PATH contents again. Here is my new PATH contents:

Screenshot 2022-02-11 at 22.10.26.png

You can now observe that '/usr/local/sbin' has been added to PATH. Now launch the command 'rabbitmq-server' again and everything will work.

So you can use this technique to add files to PATH. If you want to know where your packages are located after installation you can search on google or read the package's docs to know where packages are installed after installation.

Thank you guys for reading. I really appreciate your feedback and will offer help to anyone who needs help in the comment section.