Compiled vim from source on Mac OSX and getting 'shell returned 127' error? - bash

On my Mac OSX 10.6 machine, I started to use MacVIM for vim. Then I noticed my terminal version was different to the MacVIM version (MacVIM was 7.3 and my terminal version 7.2)... I thought they used the same vim?
I need 7.3 for some of the features. So I set about wanting to update the terminal version. I basically cloned it using Mercurial (the perferred way according to the official site) and then did the usual to compile it. This did work and I now have 7.3 in my terminal. But, on some commands when exiting, I can this error:
/bin/bash: q: command not found
shell returned 127
Press ENTER or type command to continue
...I've tried my hardest to try and fix this problem, but trying to reinstall MacVIM, deleting the vim in my /usr/local/bin and compiling again and I just can't get rid of this annoying error.
Can anyone possibly help me? Am I doing this all wrong? ...most of the time I will be using MacVIM, but it'd be nice for me to have it in the Terminal - exactly how I'd have it on my Ubuntu servers.
Any help would be fantastic!

:!q is not :q!. This is probably not a bug.
The error message you're seeing is is most likely the result of accidentally typing :!q instead of :q!, which would be user error, not a bug. :!q shells out to run q, and your shell (bash) is not finding such a command and bails with 127. (For comparison, you might try :!true, :!false, :!vim %, to get a feel of this.)
There isn't really a “fix” for this, and ! is really useful for other purposes; maybe with more practice you'll make the typo less often. You could also try using ZQ instead of :q!; this has other disadvantages (a typo ZZ will instead save the file if it's edited, and ZQ specifically is a vim extension), but at least you see this error again.
The upshot here is basically check to make sure you typed in your commands right, I guess.

I'm not sure on the exact path, but somewhere a few folders deep into the Applications/MacVim.app folder is the vim executable that will also run in a terminal (Use the -g option to launch it in GUI mode).
You should be able to throw this in your .bashrc:
alias vim=/Applications/MacVim.app/Contents/MacOS/vim

This is the homebrew formula for vim. Try these settings for "configure" or just install homebrew and install vim from there.
system "./configure", "--prefix=#{prefix}",
"--mandir=#{man}",
"--enable-gui=no",
"--without-x",
"--disable-nls",
"--enable-multibyte",
"--with-tlib=ncurses",
"--enable-pythoninterp",
"--enable-rubyinterp",
"--with-features=huge"
system "make"
system "make install"

Related

Why shell always execute vim in /usr/bin rather than vim in /opt/homebrew/bin?

I don't want to use the vim bundled on the macOS, so I download new vim using homebrew.
My environment variable PATH is set as follows:
/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin. The vim downloaded using brew in in /opt/homebrew/bin, and vim bundled with macOS is in /usr/bin. However, when I input vim on the shell, it always execute /usr/bin/vim(i.e. the vim bundled with macOS).
Does anyone know how to solve this or what is the reason for this circumstance? Very appreciate any help.
Oh! I know why is that. After installing new vim using brew, we need to reboot the terminal. I know this because I I accidentally shut down the terminal, then I open the terminal and find the vim in /opt/homebrew/bin can be executed when I input vim in the shell.
For beginners, this is a difficult problem to find the reason. I solved this problem myself, hoping to help people who encounter the same problem

Brew update failed on Yosemite

I upgraded my Mac to the new OSX 10.10.
brew update failed with:
/usr/local/bin/brew: /usr/local/Library/brew.rb: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby: bad interpreter: No such file or directory
/usr/local/bin/brew: line 23: /usr/local/Library/brew.rb: Undefined error: 0
I tried to follow "Getting a "bad interpreter" error when using brew", but I couldn't get it working.
I do not have Ruby in /usr/local/bin or /user/bin, which may be for same reason which ruby returns nothing.
I have Xcode 5.1 with the command line tools installed. Whenever I start terminal I get:
-bash: /etc/profile.d/sm.sh: No such file or directory
-bash: /etc/profile.d/rvm.sh: No such file or directory
Can anyone suggest possible solutions?
First off upgrade Xcode to 6.1 This is the version that works with Yosemite.
After that make sure you RUN Xcode and Agree to the license ( i know it sucks ).
Note: After Updating My "Oh My Zsh" tools and restarting Xcode it installed some command line tools that I'm pretty sure are important.
There are things to note:
Mac OSX does come with a Ruby preinstalled in /bin/ruby. That is Apple's own installation, used for some of their tools, and basically should be ignored. Updating it could break those tools, and worse, deleting it, will break them. Trying to reinstall it is a pain, so it's better to pretend it isn't there.
We generally recommend using either RVM or rbenv to manage/install any other Ruby version. Those tools are well tested and make it easy to switch back and forth between versions.
rbenv is easier to manage but lacks some of the features of RVM.
Closely follow the RVM installation instructions if you go that way; We see a lot of questions on Stack Overflow caused by people who ignore the directions, or who follow directions on a different site besides RVM's home site. (The RVM authors really do know better than anyone else how to make it work.)
Brew can install Ruby, but switching between versions gets stickier.
It sounds like your PATH variable doesn't include /usr/bin, which is odd, because it should. If it did, it should find the default Ruby.
echo $PATH
will display your search path. It's editable and, if
ls /usr/bin/ruby
shows that Ruby does exist in /usr/bin then you should add it back into the path. You can do that by editing ~/.bashrc, but also check ~/.bash_profile to make sure something isn't messing up the path. And, if you don't understand how the path works, take the time to read about it, because a badly set-up PATH variable can slow your use of the command-line, or cause all sorts of weirdness.
By default there is no /usr/local/bin/ruby. It won't exist using RVM or rbenv either, but Homebrew will probably put a symlink; I don't have it supplying my Ruby, so I can't check that.

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

bash __git_ps1 command not found

I am a beginner trying to setup a developer environment on my new Mac following the steps from this link: http://vanderveer.be/setting-up-my-perfect-developer-environment-on-osx-10-8-mountain-lion-10-8-2-final-edition/.
After executing the files from git, my terminal window now shows:
rbenv: version `1.9.3-p194' not installed
-bash: __git_ps1: command not found
The first line only shows when I open a new terminal window, while the second shows everytime I press return no matter what I type into the terminal.
I have read through many questions on stackoverflow and tried to mimic their solutions to no avail. I think I've made a mistake in installing the package from git as I am not so experienced and I think now I may have messed up the configurations, and was also wondering if there is any way to go back to default settings for bash?
Many thanks!
Allen
If you've not installed a newer version of Git on your Mac, start by doing that. You can grab the download from here: http://git-scm.com/download
Once it's installed, you should source git-completion.sh and git-prompt.sh from your ~/.profile (or ~/.bashrc, if you have it):
source /usr/local/git/contrib/completion/git-completion.bash
source /usr/local/git/contrib/completion/git-prompt.sh
That should fix the __git_ps1 error.
I'm not a Rubyist, but the rbenv error is coming from the fact that the setup in the dotfiles you are following is trying to set the default Ruby version to "1.9.3-p194". The rbenv tool is there to make a number of different Ruby versions available, but you have to install them first. In your case, I think you need to run this:
rbenv install 1.9.3-p194
After that, the version will be available, and you shouldn't see the warning anymore.

How do I get autochdir to work on a Mac when running Vim from the terminal?

In MacVim autochdir works without a problem. However, lately I've been running iTerm2 (full screen with split) for coding and the lack of autochdir is really bothering me. Any solutions? Thanks.
What do you mean by "the lack of autochdir"? It works fine both in CLI and in GUI.
If you have set autochdir in your ~/.vimrc this feature will work the same way whether you are in MacVim or iTerm2 or Terminal or whatever.
But I suspect you are changing dirs in an iTerm2 split and expecting Vim to somehow learn about that change and change its pwd accordingly. Am I right? "Unfortunately" Vim doesn't know about the second iTerm2 split and can't react to your cd there.
In the terminal:
> which vim
If it says /usr/bin/vim, you're using the mac base installation. This is an old version of vim and doesn't support autochdir. You'll need a newer version.
Check if you have another installation of vim by running:
> /usr/local/bin/vim
If so, add /usr/local/bin to your $PATH before /usr/bin
If not, install it:
> brew install vim

Resources