Skip to content

Instantly share code, notes, and snippets.

@lenciel
Created October 26, 2012 06:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lenciel/3957313 to your computer and use it in GitHub Desktop.
Save lenciel/3957313 to your computer and use it in GitHub Desktop.
Build vim on ubuntu 10.04 64bit with python and ruby support

By installing Vim with ruby support from the sources, it is build against the system wide installation of ruby. If you already installed Vim and/or ruby with sudo apt-get install vim (or sudo apt-get install ruby) or with brew install vim (e.g. brew install ruby) if you are using OS X, remove it completely from your system to install the latest version of Vim.

Install rbenv

I'm installing rbenv on different machines so I created the following script (named rbenv_install.sh) to install ruby 1.9.2-p320:


cd $HOME
sudo rm -rf .rbenv
git clone git://github.com/sstephenson/rbenv.git .rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile

install steps for rbenv-install command


cd $HOME/Downloads
sudo rm -rf ruby-build
git clone git://github.com/sstephenson/ruby-build.git
cd ruby-build
sudo bash install.sh

updating the current shell


cd $HOME
exec $SHELL
source $HOME/.bash_profile

rbenv-install 1.9.2-p290
rbenv rehash
exec $SHELL

After this try the following:


$ rbenv global 1.9.2-p320
$ rbenv local 1.9.2-p320
$ ruby -v
=> ruby 1.9.2p320 (2012-04-20 revision 35421) [i686-linux]
The crowd applauds.

GET THE LATEST VERSION OF PYTHON

This will be put in the $HOME/lib folder:


$ mkdir $HOME/lib
$ cd $HOME/Downloads
$ wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2
$ tar xjvf Python-2.7.3.tar.bz2
$ cd Python-2.7.3
$ ./configure --prefix=$HOME/lib
$ make && make install
$ make inclinstall # install headers, otherwise Vim won't have Python support
$ hash -r

GET THE LATEST VERSION OF VIM

Visit vim.org and select the right download for your operation system (mainly Unix). If you are using a Unix system yo can get the latest Vim from here, download and unzip it:


$ cd $HOME/Downloads
$ wget ftp://ftp.vim.org/pub/vim/unix/vim-7.3.tar.bz2
$ tar -xjvf vim-7.3.tar.bz2

It is also possible to get the latest Vim version from the git repository with the following command:


$ cd $HOME/Downloads
$ git clone https://github.com/b4winckler/vim
$ cd vim
$ git tag -l
$ git checkout v7-3-548

COMPILING VIM AND GVIM

To install Gvim on Ubuntu we need to install additional packages on our machine. The following snippets describe the packages for Ubuntu:


$ sudo apt-get install libncurses-dev libgnome2-dev \
 libgtk2.0-dev libatk1.0-dev libbonoboui2-dev libcairo2-dev \
 libx11-dev libxpm-dev libxt-dev

Since we are now having the Vim sources under $HOME/Downloads/vim it's time to start the compilation. First we need to configure our compilation:


$ cd $HOME/Downloads/vim
$ ./configure --prefix=/usr/local \
    --enable-gui=no \
    --without-x \
    --disable-nls \
    --with-tlib=ncurses \
    --enable-multibyte \
    --enable-rubyinterp \
    --enable-pythoninterp \
    --with-python-config-dir=$HOME/lib/python2.7/config/ \
    --with-mac-arch=x86_64 \
    --with-features=huge \
    --enable-gui=gnome2

Let's get over the heavy stuff:


--prefix=/usr/local - place of the binaries of the installed Vim installation (check the /usr/local/bin) - there will be the executable binaries
--enable-rubyinterp - says you want to build Vim with the default ruby installation (in our case /home/mg/.rbenv/shims/ruby)
--enable-gui=gnome2 - building Vim with Gvim support (if you don't want Gvim than you can leave this line out)

After configuring the compilation check if the console response contains the following terms:


checking --with-ruby-command argument... defaulting to ruby
checking for ruby... (cached) /home/mg/.rbenv/shims/ruby
checking Ruby version... OK
checking Ruby header files... /home/mg/.rbenv/versions/1.9.2-p320/include/ruby-1.9.1

If you can't see the lovely Ok, your Vim compilation will probably not have ruby support. After that we can build the configuration, install, and clean everything up:


$ cd ~/Downloads/vim
$ make
$ sudo make install
$ sudo make clean

CHECK THE INSTALLATION

Open a new session or perform exec $SHELL to reboot your Shell. You will see the fresh installed version of Vim:


$ which vim
/usr/local/bin/vim

$ which gvim
/usr/local/bin/gvim

Next check is to get the correct --version of vim and gvim with the following commands:


$ vim --version | ack ruby
$ vim --version | ack python
$ gvim --version | ack ruby
$ gvim --version | ack python

If both commands return +ruby and +python, you are fine, and got the achievement "I installed vim form source with ruby support on my own". You should now be able to run the Hammer.vim plugin - install it, start it with :Hammer, install the missing gems and if you are able to run :Hammer without any missing dependencies, you have setup everything correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment