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

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.

Related

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.

Terminal commands can not be found OSX

A majority of terminal commands don't work, for example .
ls
sudo
vi
with the error -bash: ls: command not found my path is echo $PATH
“/Users/username/usr/local/bin I get the feeling that “ should not be there but not sure how edit it.
What should the path be and how do I get the path to stay the same?
You need to add more paths to your $PATH variable. Try running whereis ls and check where is the binary of the command.
You can add more paths like this: export PATH=$PATH:NEW_PATH
I had a similar experience recently where a lot of my terminal commands were not being found despite being clearly saved in my bash_profile. After lengthy process of elimination I realised that the issue was caused when I tried to export a new path. The error that I had made was putting a space in the command. So I had to change
export SOMETHING = /path/to/something.apk to
export SOMETHING=/path/to/something.apk
So I would recommend you check all your path declarations to ensure you don't have any white spaces. Also don't forget to source your bash_profile or what ever type of command line shell you use.

Why can't I add PostgreSQL to my path?

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

-bash: sudo: command not found Mac OS X (EC2 CLI prob?)

Getting the error:
-bash: sudo: command not found
echo $PATH outputs PATH:EC2_HOME/bin
I'm running Mac OSX 10.8.3
That seems wrong even for a n00b like me.
How do I fix my $PATH and return my computer to it's former self?
As stated in the comments the right files to set up your $PATH variable are: ~/.profile or ~/.bash_profile
export PATH=/usr/bin:/usr/sbin:/bin:/usr/local/bin:/sbin:/opt/x11/bin:$PATH
In this way when you re-enter in the console your PATH will work fine.
You can add other directories to your $PATH as you like.
If you just copy and past that line in an active console you just set the PATH variable temporary, when you logout and login again you will loose your path, so add it in your ~/.bashrc file.
I'm not sure how you've managed to get into that state, though this article explains how you can set your path.
If it helps, the output from my echo $PATH is: -
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin
go to shell
choose new command
put this : sudo vim .bash_profile
then put : export PATH=/usr/bin:/usr/sbin:/bin:/usr/local/bin:/sbin:/opt/x11/bin:$PATH
This worked for me:
echo $PATH
Followed by:
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"

Mac OSX .zshrc $PATH variable ignorning local command

I'm on MacOSX Mountain Lion 10.8.2, using OhMyZsh and for some odd reason, I am not able to run a command which should trigger a script in my local directory. If I navigate via terminal to the folder containing "tidy" (http://w3c.github.com/tidy-html5/) I get an error when trying to run it:
➜ tidy test.html test.min.html
zsh: command not found: tidy
My $PATH variable looks very weird in .zshrc (I'm new to zsh, I've always used bash):
export PATH=$PATH:/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/bin:/Users/Keith/.rvm/bin
Does anyone know what I could do to modify my path to check the local working directory first?
Thanks a ton
The current working directory is . which doesn't appear to be in your $PATH. You can export it the same way you would in bash:
export PATH=.:$PATH
which will add . before the rest of $PATH. You'll need to either source ~/.zshrc or re-open your terminal window to apply the changes. You can check whether . is in the $PATH:
echo $PATH

Resources