Vim 7.4 installed but executes Vim 7.3 when running - macos

I have installed Vim-7.4 on my OS X El Capitan. Just to make sure, executing brew install vim and brew install vim --override-system-vi returned the message:
Warning: vim-7.4.1952 already installed
However, executing vim in the terminal still throws YouCompleteMe unavailable: requires Vim 7.3.598+ and within vim :version reported:
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Apr 5 2016 14:53:37) and so on.
My question is almost identical to this and this, but running hash -r and restarting a new shell did not fix the problem (also, which vim shows /usr/bin/vim, but executing /usr/bin/vim gets me the same YouCompleteMe unavailable message indicting incompatible Vim), hence I think the problem is different.
PS. I also suspect the behavior has something to do with my system found Vim-7.3 and executed it before it found Vim-7.4. Here is where I got my idea.

You need to execute the version that homebrew installs, and that resides in /usr/local/bin. So you either need to use:
/usr/local/bin/vim
or set your PATH so that /usr/local/bin appears before /usr/bin:
export PATH=/usr/local/bin:$PATH
whereby the latter is preferable and should be done in your login script in $HOME/.profile.

Related

ZSH: Command not found - after update macOS to 10.15.1

Yesterday I was using all my installed packages without any problem such as mysql, composer, php, brew and co...
However, today I started my MacBook and typed mysql and I got: zsh: command not found: mysql. Not even brew is working anymore and I don't know why.. this is my .zshrc config file and I don't know why it isn't working.
# If you come from bash you might have to change your $PATH.
export PATH=$HOME/bin:/usr/local/bin:~/.composer/vendor/bin:$PATH
Any ideas how to fix this?
Yuck, how did that happen? Try this:
PATH=/bin:/usr/bin:/usr/local/bin:$PATH
export PATH
Whether this works is going to depend on where you have been installing user executables. If you're using homebrew, I would expect it to be /usr/local/bin but perhaps it is something different in your case? You might want to try putting /usr/local/bin first so things installed by homebrew get picked up before the defaults in /usr/bin and /bin (this is what I do, and I'm still alive to talk about it...)
You could also change your default shell back to Bash:
brew install bash
echo '/usr/local/bin/bash' >> /etc/shells
chsh
You might need to use sudo on line 2.

Apple's vim always used instead of homebrew

I'm seeing something very odd, and honestly I'm stumped.
The version of vim that comes with mac is outdated (7.3 instead of 7.4). I'm trying to install vim from homebrew, and I want to use that one instead of the default apple version.
I ran "brew install vim". It installed correctly in /usr/local/bin/vim. All good.
When I run "which vim", it prints "/usr/local/bin/vim". The Apple version of vim is installed at /usr/bin/vim. So the which command is telling me that I'm using the homebrew version of vim.
However, when I actually run vim, it still runs the Apple version
$ vim --version
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Jul 9 2015 23:58:42)
Compiled by root#apple.com
...
If I run the homebrew version explicitly, I see this:
$ /usr/local/bin/vim --version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Oct 23 2015 18:16:35)
MacOS X (unix) version
Included patches: 1-898
Compiled by Homebrew
...
I even tried moving /usr/bin/vim to /usr/bin/vim73 to try to force using the homebrew version. However, when I did this, here is what I see when I try to run vim:
$ vim --version
-bash: /usr/bin/vim: No such file or directory
$
What is going on? How can I get it to run the homebrew version of vim?
Start a new shell session and it’ll work.
Bash caches executables’ paths so when you run vim it looks at your PATH to find the first executable with this name. It caches it and the second time you run vim it remembers vim is actually /usr/bin/vim and runs that.
Since you haven’t restarted your Bash session its cache is still the same; hence the error you’re seeing. It has nothing to do with the way you installed vim.
If you don’t want to start a new shell session, you can run hash -r to tell Bash to clear its executables memory.
You forgot an argument:
$ brew install vim --override-system-vi

Warning: vim-7.4.712_1 already installed, it's just not linked

Disclaimer: Complete Noob
I just started using OS X for the first time. Decided to start using vim. I installed vim with YouCompleteMe. However, when I realized I did not have the appropriate version to use the plug in, I believe I reinstalled on top of the existing installation which I read afterwards was bad. I then tried installing through brew by using the command
brew install vim --override-system-vi
Now I get the error
Warning: vim-7.4.712_1 already installed, it's just not linked
All I want to do is install vim 7.4 so I can install YouCompleteMe.
When I run the vim command I get all this junk
Error detected while processing /Users/raulalan/.vimrc:
line 50:
E117: Unknown function: vundel#rc
line 59:
E492: Not an editor command: ^D # This means Ctrl+D
YouCompleteMe unavailable: requires Vim 7.3.584+
Is this due to installing on top of the existing directory without using the -override-system-vi flag. Help is super appreciated since I feel completely lost using these new environments.
Brew is telling you that you installed vim, but for some reason it can't be linked. This is usually because there are other files around that brew doesn't know about, and doesn't want to delete.
To link vim, run brew link vim. Brew may refuse to link, and instead tell you that linking would delete some files. In that case, use brew link vim --overwrite.

Installing vim with homebrew assistance

I tried to install YouCompleteMe on Mac for vim, but I've been using the system vim which is version 7.3. I tried to update my vim using homebrew by typing brew install vim and everything seemed to be fine.
When I type vim I still see the system vim loading (version 7.3).
I feel like I'm missing a step that's keeping me from using the updated vim I got from homebrew. Does anyone know what I'm missing?
For reference when I type which vim I get the following output /usr/bin/vim. Any help would be greatly appreciated.
Just install vim via homebrew:
brew install vim
Then restart your shell:
exec -l $SHELL
And check the version:
$ vim --version|head -n 1
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Mar 9 2016 19:07:39)
You should probably have done brew install vim --with-override-system-vi. This will replace default vim path.
You're loading your system vim first, as you can see by which vim returning /usr/bin/vim instead of /usr/local/bin/vim.
/usr/local/bin is homebrew's path.
Make sure that your path lists /usr/local/bin before /usr/bin:
/usr/local/bin:/usr/bin
This will allow homebrew's vim to be sourced before the system vim.
To view your path:
echo "$PATH"
Rather than reinstalling vim you can move your current vim to vim73 (or something similar).
First check if /usr/local/bin is present in PATH environment variable. Doing echo $PATH on your terminal should do that.
Install vim with homebrew if you haven't already.
brew install vim
Then move your current vim installation.
mv /usr/bin/vim /usr/bin/vim73
Run which vim to confirm. It should say /usr/local/bin/vim.
brew install vim --with-override-system-vi (missing the with-)
echo 'export PATH=/usr/local/bin:$PATH' >> ~/.bash_profile
source ~/.bash_profile
Run this command and it will be fixed.

Homebrew version of vim won't open files

I installed vim via brew so I could have the latest version (7.4) and get syntax highlighting for Clojure. No big deal. Unfortunately, the brew version of vim seems to be broken on my system. I also aliased the vim command:
brew install vim # Install went successfully
alias vim=/usr/local/Cellar/7.4.052/bin/vim # Shouldn't be any problems here
When I open the brew version of vim, it fails to load any of my plugins (I use spf13) throwing a bunch of "Undefined variable" and "Invalid expression", etc errors for every plugin in my bundle directory; I just hit enter to continue. My .vimrc loads properly. When I open a file, it opens two tabs, both blank. One is a new file, the other is the file I tried to open, except there's nothing in it.
Potentially useful information: echo $VIM returns an empty line, while echo $ZSH returns /User/bsima/.dotfiles as expected.
Here are my dotfiles, but I don't think the problem lies in those configuration files.
Is this a known bug? Or is something wrong with my vim install?
I have no idea what's going on and I really miss my vim :( As good as Textmate is, I can't be without vim forever.
Edit: MacVim, installed via Homebrew, kinda works. It still opens 2 tabs on startup, but it does open files for editing and saves.
I found the problem: it was with my spf13 vim config. The following commands fixed the issue, in addition to double-checking that symlinks such as ~/.vim and ~/.vimrc were correct:
> which vim # This should output /usr/local/bin/vim since I'm using Homebrew
/usr/local/bin/vim
> cd ~/.spf13-vim-3
> ./bootstrap.sh # Basically re-installs spf13

Resources