-1

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 ...
Community
  • 1
  • 1
bqui56
  • 2,091
  • 8
  • 22
  • 40

4 Answers4

7

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

Community
  • 1
  • 1
Rodrigue
  • 3,617
  • 2
  • 37
  • 49
  • Excellent advice :) However, I'd still like to see an "ls -l" of the original "mvim" file, and an "echo" of the current $PATH. Just to be sure :) – paulsm4 Jul 01 '12 at 17:19
  • I am getting: "Not a directory" when typing in the command. I made an edit to my question showing output for `echo $PATH`. – bqui56 Jul 01 '12 at 17:22
  • @paulsm4 thank you. I have updated my answer to cover the potential `PATH` issue – Rodrigue Jul 01 '12 at 17:27
  • @stariz77 Have you tried the suggested `ls` command? Can you post the output please? – Rodrigue Jul 01 '12 at 17:28
1

Check:

  1. If /usr/local/bin/mvim is executable (add exec bit if not: chmod +x /usr/local/bin/mvim)
  2. If /usr/local/bin is in $PATH (echo $PATH)
Igor Chubin
  • 61,765
  • 13
  • 122
  • 144
1

Either start a new shell, or type:

hash -r

so that the shell re-inspects the directories in the $PATH. (It caches the contents for efficiency, you need to reload that cache when you add things to directories in your path.)

Mat
  • 202,337
  • 40
  • 393
  • 406
0

This is what you posted:

mvim -> /usr/local/bin

I believe that's wrong. It looks like "mvim" is a symbolic link that points to the directory /usr/local/bin.

If so, this is not what you want!

Please do the following:

  1. Open a terminal (command-line) window.

  2. "cd" to the directory with your original "mvim" (the one you tried to copy to /usr/localbin)

  3. Cut/paste:

    a) the directory name

    b) ls -l mvim

    c) echo $PATH

The "echo $PATH" is also important.

Please cut/paste all three into your response.

Thank you in advance.

paulsm4
  • 114,292
  • 17
  • 138
  • 190