postgresqlmacosterminalpathnetlify-cli

Mac OS: How do you fix a PATH to reach an executable file (in this case postgresql & netlify-cli) without messing up other paths?


In the mac terminal:

Does anyone know how to set the path variables for a Mac OS, without messing up other paths?

Current folder structure:

/
 /Applications
    /[a lot of applications]
    /Postgres.app
        /Contents
          /Versions
              /12
                /bin
                  /psql
 /Users
    /userName
      /Applications
           /[nothing, except a couple hidden files]

Right now, if I run the command psql, I am getting:

command not found

If I type the full path:

/Applications/Postgres.app/Contents/Versions/12/bin/psql

it works, but typing this every time is not practical.

If I run git that command is available, or code .

Also, I installed netlify-cli globally with npm install -g netlify-cli, but when I run netlify-cli, I get:

command not found

and I don’t know where to find it in my system

… So, something is working correctly with my paths, and something is not. I don’t know how to fix the problem, without messing up other paths.

Does anyone know how I could find out where netlify-cli got installed and fix my paths to netlify-cli and psql without messing up any other paths?


Solution

  • For Mac OS to be able to find the psql executable, it has to be part of the PATH environment variable, you can check the value of that variable on your terminal with this command

    echo $PATH
    

    what you should do is add the psql executable to it, like this:

    export PATH=/Applications/Postgres.app/Contents/Versions/12/bin/:$PATH
    

    if that solves your problem, you can put that on your .zshrc or .bashrc to make it persistent