bashmacvim

Why isn't this file being copied to my $PATH?


I was trying to add the mvim shell script to /usr/local/bin form bash as per this question and everything seemed to work; however, I am still getting "command not found" whenever I try to execute the script.

From the directory where my mvim file is (Downloads), I typed:

sudo cp -v mvim /usr/local/bin

and I get output:

mvim -> /usr/local/bin

and then it doesn't work whether I type mvim or mvim -v

I've never added something to my $PATH before, but even after looking up a number of tutorials on how it is done, I can't seem to get mvim to work as a terminal command.

EDIT:

echo $PATH

/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin

and

ls -l mvim

-rwxr-xr-x ...

and

ls -l /usr/local/bin

-rwxr-xr-x ...

Solution

  • Does /usr/local/bin exists?

    If you run sudo cp -v mvim /usr/local/bin and the /usr/local/bin folder does not exist, cp will copy mvim to the /usr/local/ folder and name it bin.

    You need to first create the folder with sudo mkdir -p /usr/local/bin. Then, you can copy mvim with the previous cp command.

    Is mvim executable?

    Have you made sure that /usr/local/bin/mvim has the executable flag set? Try ls -l /usr/local/bin/mvim and if the result starts with -rw-r--r--, then mvim is not executable.

    You then need to run sudo chmod +x /usr/local/bin/mvim. If you now run the previous ls command again, the result should start with -rwxr-xr-x. The x means that the file is now executable by its owner, members of its group, and all other users too.

    Is /usr/local/bin in your PATH?

    Have you made sure that /usr/local/bin is part of your PATH variable?

    Try echo $PATH and if the output does not contain /usr/local/bin, then the shell will not look for commands there. You then need to run export PATH=$PATH:/usr/local/bin