Bash still trying to use uninstalled and unlinked Vim version - bash

I am trying to switch to vim 8. I uninstalled 7.4 and install 8 with homebrew. I am currently stuck with the following error:
$ vim
-bash: /usr/local/Cellar/vim/7.4.1301/bin/vim: No such file or directory
I don't understand what is happening because the linkings seems correct:
$ which vim
/usr/local/bin/vim
$ readlink /usr/local/bin/vim
../Cellar/vim/8.0.0051/bin/vim
I am using iTerm2 as my terminal and I already tried restarting it.
Edit 1: For the installation I removed vim completely using brew uninstall vim and then reinstalled it through homebrew.
Edit 2:
$ brew info vim
vim: stable 8.0.0051 (bottled), HEAD
Vi "workalike" with many additional features
http://www.vim.org/
Conflicts with: ex-vi
/usr/local/Cellar/vim/8.0.0051 (1,710 files, 23.3M) *
Poured from bottle on 2016-10-28 at 11:24:37
Edit 3: brew cleanup also did not yield a result.

Shell aliases / functions may still apply. The which command doesn't see those.
You can check with
$ type vim
vim is aliased to `/usr/local/Cellar/vim/7.4.1301/bin/vim'
Or try invoking Vim with quotes:
$ 'vim'

Related

How to install a specific version of vim (+clipboard)

I'm trying to enable copying to OSX's clipboard in vim and most resources I have found say that I need a version of vim with +clipboard. These resources also indicate that this should be as easy as running brew install vim, however, I am stuck with -clipboard even after updating. Any suggestions as to how to force this feature? Do I even need it to achieve the desired behavior?
a brew update brew install vim should give you vim with +clipboard.
However your path probably still points to the old vim. Try that:
alias vim="/usr/local/bin/vim"
probably this will also work: (Not anymore, see the Update)
brew install vim --with-override-system-vim
Addition: I recommend to install it with brew install vim --with-client-server so you will have +xterm_clipboard.
Alternativly you could install macvim which should have all these features already in:
brew install macvim --with-override-system-vim
Update
--with-override-system-vim was removed. The best solution in my opinion is to just add macvim in front of your PATH:
PATH="/Users/user/Applications/MacVim.app/Contents/MacOS/Vim:${PATH}"
export PATH
You can test if vim points to the right instance with which vim

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

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.

Update OSX Vim using MacVim

I'm trying to update Vim (for use in Terminal) on my Mac. It's currently running version 7.3, but YouCompleteMe requires Vim 7.3.584, and won't run even though it's installed.
I've tried using a Vim alias in my .bash_profile:
alias vim='/Users/Conor/Applications/MacVim.app/Contents/MacOS/Vim'
However none of my Vim plugins are launched when I run Vim like this, any my vimrc file isn't recognised either.
How can I get this alias to recognise my existing Vim settings? Or is there a better way of upgrading Vim for mac?
The *.tbz that you downloaded from the official page contains a mvim script.
Once you have moved that script somewhere in your $PATH you can start the MacVim GUI like this:
$ mvim filename
and the MacVim CLI like that:
$ mvim -v filename
From there the only thing you need is to change your alias to point to mvim:
alias vim='mvim -v'
The original built-in Vim and its runtime files stay untouched, MacVim uses its own runtime files located in the MacVim.app bundle and both honor your personal config (assuming they are located where they should be: ~/.vimrc and ~/.vim/).
Quick, clean and painless.
If you installed MacVim with HomeBrew you can use
brew install macvim --override-system-vim
If you just want pure vim with python support do:
brew install vim --override-system-vim --HEAD
I had the same issue as you, but this worked like a charm. You complete me works perfectly after this.

How do I update zsh to the latest version?

I recently switched to zsh on my Terminal.app on my OS X machine successfully. The version number of zsh is 4.3.11.
If you're using oh-my-zsh
Type omz update in the terminal
Note: upgrade_oh_my_zsh is deprecated
If you have Homebrew installed, you can do this.
# check the zsh info
brew info zsh
# install zsh
brew install --without-etcdir zsh
# add shell path
sudo vim /etc/shells
# add the following line into the very end of the file(/etc/shells)
/usr/local/bin/zsh
# change default shell
chsh -s /usr/local/bin/zsh
If you're not using Homebrew, this is what I just did on MAC OS X Lion (10.7.5):
Get the latest version of the ZSH sourcecode
Untar the download into its own directory then install: ./configure && make && make test && sudo make install
This installs the the zsh binary at /usr/local/bin/zsh.
You can now use the shell by loading up a new terminal and executing the binary directly, but you'll want to make it your default shell...
To make it your default shell you must first edit /etc/shells and add the new path. Then you can either run chsh -s /usr/local/bin/zsh or go to System Preferences > Users & Groups > right click your user > Advanced Options... > and then change "Login shell".
Load up a terminal and check you're now in the correct version with echo $ZSH_VERSION. (I wasn't at first, and it took me a while to figure out I'd configured iTerm to use a specific shell instead of the system default).
As far as I'm aware, you've got three options to install zsh on Mac OS X:
Pre-built binary. The only one I know of is the one that ships with OS X; this is probably what you're running now.
Use a package system (Ports, Homebrew).
Install from source. Last time I did this it wasn't too difficult (./configure, make, make install).
A simple script or execute following commands in terminal
# 1. download (currently the latest version is 5.8) and extract
wget https://sourceforge.net/projects/zsh/files/latest/download -O ./zsh-latest.tar.xz
mkdir zsh-latest
tar -xf zsh-latest.tar.xz -C zsh-latest --strip-components=1
cd zsh-latest
# 2. config, build, install
./configure
make -j4
sudo make install
which zsh
PS: If you fail to build, it probably due to missing necessary libraries. Just install libraries as the error message suggests. E.g, I didn't have ncurses:
sudo apt install ncurses-devel # for Ubuntu
sudo yum install ncurses-devel # for CentOS/Redhat
omz update gave me following error:
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
This is an issue with git, where after upgrading to Mac OS Ventura (13.0.1). git command gave me above error.
Solution:
Download and install the 'Command Line Tools' package to fix 'git'
xcode-select --install
This will pop a dialogue box. Select "Install".
More details here: https://apple.stackexchange.com/a/254381
omz update worked successfully after this for me
I just switched the main shell to zsh. It suppresses the warnings and it isn't too complicated.

Resources