Compiling Vim with Ruby from RVM (on Ubuntu)
The other day, I was in the position where I had to recompile Vim (and GVim) on Ubuntu. I had installed the version from aptitude, which is perfectly good apart from the fact that it requires and installs the ruby 1.8.7 package. I actually use RVM for my ruby binary management, and I wanted to tell Vim to use the ruby 1.9.3 installed on my system via RVM.
This meant recompiling, which is not too tricky. Here's how I did it.
1. Remove existing versions
This will depend on the OS, but for Ubuntu you can do:
And whichever vim related packages you might have lurking on your machine.
If you didn't install Vim through a package manager (i.e. compiled it), then you can run make uninstall
in the source code directory that you used to compile. If that no longer exists, it's a case of removing the binaries manually, or hoping for the best.
2. Get source code
I followed the instructions at http://www.vim.org/mercurial.php, to get the latest code base using Mercurial. If you don't have Mercurial and you are using Ubuntu, it's a simple case of apt-get install mercurial
.
Then, to download the sources:
The last two commands are probably not necessary, as the clone should give you the updates.
3. Install libraries for Gvim
If you want to compile Vim with support for the graphical version, Gvim, you will have to install the development versions of libatk, libgtk, libbonoboui2, libcairo2, libx11, libxpm, libxt and libgnome2 (if using Gnome). In Ubuntu, you can just run:
This will be different if you're using a different distro or package manager.
4. Configure for your environment
Now to configure Vim with the options you want. I wanted all the major features, plus ruby and python support. I also wanted to install GVim, and to integrate it with gnome. In the vim source directory, run:
To get all the options. For my setup, I used:
The things to change are the python config directory and ruby command. The ruby command is whichever ruby binary you want to use, and specifying a different version here will be fine. Also, if you aren't using gnome window manager then you will want to change the --enable-gui
value to something else like "gtk2" (see ./configure --help
for all the options).
The other thing to mention is that it's including all major features with the "HUGE" value. This can be tiny, small, normal, big or huge, depending on what level you want.
Modify the command to fit your requirements and run. One reason for failure that I have had is that the ncurses library is missing. On Ubuntu you can install this with apt-get install libcurses-dev
.
Only after configure
has passed can you move on to the next step.
5. Install
Finally, after the configuration has successfully completed, you can run make
:
If that works without any errors then congratulations, your Vim is ready! There are several problems that you could run into. For instance, you might get an error like:
This means that you need the python-dev
package, which you can install on Ubuntu with apt-get install python-dev
.
6. Run and Enjoy
Check that your installation is working by running Vim and, in the command window, typing: