Why can't I add PostgreSQL to my path? - macos

After I upgraded to Mavericks, PostgreSQL started playing up, giving this error message whenever I call pg_restore without calling the full path:
pg_restore: command not found
If I specify the full path it works, but that's obvious not optimal:
/Applications/Postgres93.app/Contents/MacOS/bin/pg_restore --verbose --clean --no-acl --no-owner -h localhost -U steven -d db/testivate_development $file_path
To fix this problem, I have tried removing all versions of PostgreSQL (with Homebrew) and then installed Postgres.app. You can confirm this has worked like this:
$ sudo find / -name pg_restore
/Applications/Postgres93.app/Contents/MacOS/bin/pg_restore
find: /dev/fd/3: Not a directory
find: /dev/fd/4: Not a directory
To add PostgreSQL to my path, I've tried adding each of the following lines to ~/.bash_profile, ~/bashrc and ~/.zshrc, restarting after each attempt:
export PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"
...as per the postgresapp.com documentation, and then...
export PATH="/Applications/Postgres93.app/Contents/MacOS/bin:$PATH"
...as per the comments below.
None of this has solved my problem.

Try adding this line to your .bash_profile:
export PATH="/Applications/Postgres93.app/Contents/MacOS/bin:$PATH"
and remove or comment out the previous reference.

I had this problem too, so instead of adding this to my path in .bash_profile:
export PATH="/Applications/Postgres93.app/Contents/MacOS/bin:$PATH"
which is what had been recommended, I added
export PATH="/Applications/Postgres.app/Contents/Versions/9.3/bin:$PATH"
instead. The '9.3' is replaced by your own version.
I verified it afterwards using
which psql
And it found my version, whereas before it reported nothing.
I then then created a test database with
createdb test
This worked like a charm.

If you are using zsh, try this line in your .zshrc and then restart the terminal
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/9.4/bin

The examples others are giving that do export PATH=... should be the solution to your problem. Since it's not working, you're going to have to debug a problem with your shell that has nothing to do with PostgreSQL.
Firstly, do which pg_restore to see if there is another file called pg_restore in your path that is confusing things. which will usually give no output rather than a helpful error if nothing is found, otherwise it will print the path of what it did found. You may find an old broken install of PostgreSQL in /usr/local/bin, for example.
If that didn't work, try echo $PATH from a new shell. Do you see the path to the PostgreSQL binary directory in there? If not, $PATH is not being set in your shell dot-rc files. This would be the case if you added it to a file called ~/bashrc since bash(1) actually read ~/.bashrc. Note the extra dot! I suspect this is your actual problem.
If that turns out to not be the problem, you can (re)read the rc file into your current session with source ~/.bashrc. Again, echo $PATH If it still doesn't contain the path, the dot-rc file contains a bug and is not being executed as far as the part that updates $PATH. You can do bash --verbose ~/.bashrc to run it, and you'll see each command as it's being executed. The failing command should be the last one displayed. (Note that when you run a script with bash, it will not set variables in your current shell.)

You need to add the path in your bash_profile
nano ~/.bash_profile
Add this line (my postgres version is 9.1):
export PATH=$PATH:/Library/PostgreSQL/9.1/bin/

On macOS Sierra 10.12.1 with PostgreSQL 9.6.0.0
/Applications/Postgres.app/Contents/MacOS/Postgres
Postgres is binary file.

On my macOS, Postgre 9.6 is installed in
/Library/PostgreSQL/9.6

on macOS High Sierra 10.13.2 and PostgreSQL 9.6 it works for me:
export PATH=$PATH:/Library/PostgreSQL/9.6/bin:$PATH

Related

zsh: command not found: mv (I'm trying to move composer.phar)

I'm trying to follow a course on Udemy (laravel). I just downloaded XAMPP (I'm on macOS Monterey) and I edited the ~/.zshrc file and added export PATH=/Applications/XAMPP/bin
After that I installed composer which worked successfully, but now when I try to run this command: mv composer.phar /usr/local/bin/composer the shell responds with: zsh: command not found: mv.
Does anyone know how to fix this?
You messed up your PATH. Do a
path+=(/Applications/XAMPP/bin)
instead of the export PATH=... you are using now. And since you want to fiddle with the PATH in your .zshrc, I also suggest to do a
typeset -aU path
near the top of your .zshrc to avoid duplicate PATH entries when you launch an interactive subshell.
The file mv was not found in your PATH, is your PATH variable setup correctly?
Enter echo $PATH to see your PATH variable.
Try /bin/mv to see if the binary file exists.

-bash: ghci: command not found (Haskell interactive shell, Haskell installation )

edit : I ended up upgrading to macOS Catalina yesterday and replacing bash with zsh. One thing that should be noted is that the stackcommand worked previously, but despite all the tinkering not ghci
After deleting all the files that had anything to do with Haskell, I retried running curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
This second time there was an error with the command line tools so I had to install them manually with xcode-select --install. After rerunning the curl, I added the path to the environmental file to my zsh profile manually with :
. "$HOME/.ghcup/env"\
echo '. $HOME/.ghcup/env' >> "$HOME/.zshrc"
Here is the content of the env file :export PATH="$HOME/.cabal/bin:/Users/agnel/.ghcup/bin:$PATH"
Now everything seems to be working (I never reinstalled stack, but I think I might leave that to the side while I learn the basics of the language).
I installed the Haskell Platform yesterday but am having a hard time getting it to work correctly.
The firsts steps I did are:
curl -sSL https://get.haskellstack.org/ | sh
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
On step 1. the instructions said to append /Users/.../.local/bin the PATH variable (which I did in /etc/paths. On step 2, the script was supposed to pop up a dialog box (and didn't) when installing the necessary command line tools. It also said to rerun the script once complete (which I did). The script also said I should adjust my PATH variable, and source /Users/.../.ghcup/env in my shell configuration. It asked to this automatically but failed having not found the ~/.bashrc File. (I read that on Mac in contrary to linux, only .bash_profile is loaded upon opening of a terminal window so I adjusted the path variable there manually. I've spent forever messing around with the path variables and every time I try and run "$ ghci" I get the same -bash: ghci: command not found error message. If anyone has a solution to this problem I would be very grateful for an answer. If not, could someone with a working distribution of Haskell on their computer show me what their path variables look like?
Thanks!
A simple solution would just be to restart your terminal and you are good to go.
After installing the Haskell platform for the first time on a new mac with Catalina, I also got
~> ghci
zsh: command not found: ghci
What worked in my case was to use, instead of the plain ghci,
stack ghci
To get back the familiar behaviour, I created in my homedirectory a file named .zshrc containing
alias ghci='stack ghci'
If you open a new terminal, this file will automatically be executed.
I'd be interested to know if there is another solution.
Check if the ghcup command is working or not.
If not, make sure the .zshrc file has command for execution of ghcup. It should look something like this -
[ -f "/Users/myusername/.ghcup/env" ] && source "/Users/myusername/.ghcup/env" # ghcup-env
If the file exists, simply restarting terminal will work.
If it is still not working, set GHC as default using ghcup - follow this

source /.bash_profile command not working

I am trying to refresh my aliases on my Mac (OS Catalina 10.15.6) after defining new aliases in my .bash_profile file with the command:
source ~/.bash_profile
But terminal keeps giving this error message:-bash: s: command not found
This is confusing because for the longest time this command worked. I even had it included in my .bash_profile file as an alias, where it worked fine.
I'm aware the problem could have to do it with an error in my PATH but I've never made any edits to my PATH so have no idea what the issue could be?
Thanks in advance.
My first instinct would be to check both ~/.bashrc, and /etc/bashrc if it exists. That is where I customarily define aliases, and it looks to me as though a bad alias may be your problem.
I'm not saying it was the one you made, although it might be. Just go through your rc and profile files and look for any aliases which might in any way clash with source.
I suspect the source command is working just fine and the problem is a bad line in the ~/.bash_profile itself that looks like it's trying to run a command named s. I would look in there for the problem.
It might help to run it with xtrace on via bash -x ~/.bash_profile – running it in a separate process like that won't have any of the presumably-desired side effects of sourceing it in your current shell, but you can see what it's trying to do so that you can fix it.
(You can also just set -x before the source and get both xtrace and running in the current shell; just be sure to set +x afterwards or your shell session will be full of debug output.)

ctags error with mac

I have exuberant tags in my mac. Since, yesterday i am getting this error
ctags: illegal option -- R
usage: ctags [-BFadtuwvx] [-f tagsfile] file ...
I have followed the steps mentoned in this
After following the steps mentioned here i can run ctags -R from command line(iterm)
But when i execute the same command from a .sh (i have a shell script where i run the cscope and ctags command using it) file i get the above error again but not when i run ctags -R from iterm directly.
Any pointers on solving this issue will be really helpfull.
Thanks in advance
So, the above issue seems to be fixed. The issue being that inside the ~/.bash_profile PATH variable should be set correctly. Even though my PATH variable was pointing to /usr/local/bin but /usr/bin appeared ahead of /usr/local/bin , hence somehow the ctags (when run from shell script) was picking up /usr/bin and not /usr/local/bin (which i have set alias to). Just move /usr/local/bin ahead of /usr/bin and it worked fine.
Solution
Type this in terminal:
export PATH="/usr/local/bin:/usr/bin:$PATH"
Along with Neil answer you can simply add alias ctags='/usr/local/bin/ctags' to your .bashrc file.

In Mac OSX 10.5, it can't find my Terminal commands sudo, find, etc

I don't know what has happened, but in my Terminal on Mac OSX 10.5 it can no longer find my sudo command, or find command, etc. They are there because if I put /usr/bin/sudo or /usr/bin/find it works fine...
My .bash_login file looks like this:
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/bin$PATH"
My .bash_profile file looks like this:
export PATH="/Library/Frameworks/Python.framework/Versions/Current/bin:/Library/Python/2.5/site-packages/django_trunk/django/bin:/usr/local/mysql/bin:/usr/bin/sudo$PATH"
I'll say now, I don't really know what I'm doing with the Terminal. I'm just a beginner to it all, and I must of done something for the environment variables (is that what they're called?) to be lost. I presumed I'd just have to make sure the /usr/bin/ path is in my bash files, but they are, and it doesn't seem to work. Please help!
Also, when I do use the /usr/bin/find command, it says "Permission denied" to me, even though I am logged into Mac OSX as the System Administrator account. I don't understand.
Any help would be grand. Thank you - James
It looks like both of your PATH exports are malformed:
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/bin$PATH"
The end bit there won't work. It should be:
export PATH=/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/bin:$PATH
Notice the colon before '$PATH'? It's important ;)
Also, the double quotes are not necessary.
If this doesn't work, we will need more information. It is possible that something else is modifying your path even after your shell configurations are loaded.
Can you post the results of:
$ echo $PATH
Configuration files are not always a good indication of the current environment variables, since they are modified by many programs and files, all across your system. To see all of your environment variables, you can run:
$ env
This should fix the problem completely and permanently.
first, export environment paths by using below command in the terminal.
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/b‌​in
now you have the commands you want. (eg. try ls. You'll see the command is working). But this is only for the current session. If you close the terminal and open a new one, you will have the previous issue. To make this change permanent, use below command,
go to home directory
cd ~
open .bash_profile file in nano / vim (I'm using nano here)
nano .bash_profile
This will open up nano editor. In a new line, paste the following;
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:$PATH
press 'control'+'o' to save (WriteOut) and 'control'+'x' to exit nano.
All done ! Now try the commands.
Check out --- http://www.sweeting.org/mark/blog/2008/05/26/mac-os-x-tip-setting-path-environment-variables
I went trough the same issue and here is how I solved it.
First of all I reverted the file to its original doing this way
/usr/bin/nano ~/.bash_profile
In my case I was not able to make work any command alias. Even vi or vim didnt work without specifying the full path of that command.
If nano is not installed just replace nano in the command by the editor installed
After that just restart the computer. In my case as I said bellow I could not use any command. When trying to do /usr/bin/source ~/.bash_profile
that command failed. So I had to restart the OS and it worked

Resources