CentOS: rpmbuild-ing Vim w/ Ruby support

Recently I switched from Ubuntu 11.04 to CentOS 5.7, only to find out that CentOS’s version of vim was build sans Ruby support:

$ vim --version | grep ruby
+python +quickfix +reltime +rightleft -ruby +scrollbind +signs +smartindent

“-ruby” means that Ruby support is not available. This was an unhappy moment, as I’d been a big fan of Command-T, an excellent plugin for Vim requiring Ruby support. There are a couple of blog posts about it, but required consolidation, so here is my (mostly) repost on the solution.

The posts recommend setting up an “rpmbuild” environment for building from source, which is basically user “rpmbuild”, plus a “~/.rpmmacros” definition, plus the source RPM.

1. If “rpmbuild” already exists, the following part is not required:

# useradd rpmbuild

2. Now switch to “rpmbuild”:

# su - rpmbuild
$ vim ~/.rpmmacros

3. “.rpmmacros” is a file with the following contents:

%_topdir /home/rpmbuild/rpm
%_tmppath /home/rpmbuild/rpm/tmp

4. My build is for x86_64, so replace “$ARCH” with “x86_64”:

$ mkdir -p rpm/{BUILD,RPMS/$ARCH,RPMS/noarch,SOURCES,SRPMS,SPECS,tmp}
$ mkdir -p rpm/{BUILD,RPMS/x86_64,RPMS/noarch,SOURCES,SRPMS,SPECS,tmp}

5. Next, get the source RPM, removing the “perl-devel” dependency from “vim.spec”:

$ cd rpm/SRPMS
$ wget http://ftp.redhat.com/pub/redhat/linux/enterprise/6Server/en/os/SRPMS/vim-7.2.411-1.6.el6.src.rpm
$ cd ~
$ rpm -Uvh --nomd5 ~/rpm/SRPMS/vim-7.2.411-1.6.el6.src.rpm
$ vim rpm/SPECS/vim.spec

BuildRequires: python-devel ncurses-devel gettext perl-devel
BuildRequires: python-devel ncurses-devel gettext

6. Now we are ready to start the build process:

$ rpmbuild -bb ~/rpm/SPEC/vim.spec

7. If “rpmbuild” is not installed — mine wasn’t — use “root” to install “rpm-build” first:

# yum install -y rpm-build

8. Assuming #6 completed successfully, we can use “root” to install the built RPMs:

rpm -Uvh ~/rpm/RPMS/x86_64/vim-{m,c,e}*




Ruby/RubyGems on SimplyMEPIS 6.0

# whoami
# gunzip -dc ruby-1.8.5-p12.tar.gz | tar -xof -
# cd ruby-1.8.5-p12
# ./configure
# make
# make test
# sudo make install
# gunzip -dc rubygems-0.9.2.tgz | tar -xof -
# cd rubygems-0.9.2
# ruby setup.rb
Successfully built RubyGem
Name: sources
Version: 0.0.1
File: sources-0.0.1.gem
Removing old RubyGems RDoc and ri...
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require': no such file to load -- rdoc/rdoc (LoadError)
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
from /home/belle/Desktop/rubygems-0.9.2/./post-install.rb:103:in `install_rdoc'
from /home/belle/Desktop/rubygems-0.9.2/./post-install.rb:118:in `try_run_hook'
from setup.rb:584:in `run_hook'
from setup.rb:1322:in `exec_task_traverse'
from setup.rb:1175:in `exec_install'
from setup.rb:894:in `exec_install'
from setup.rb:712:in `invoke'
from setup.rb:681:in `invoke'
from setup.rb:1359

Hmmm. Let’s see what MEPIS is missing. It built perfectly on an unpatched version of FC6 the last time. Its probably got something to do with rdoc:

# apt-get install rdoc
# ruby setup.rb
# apt-get install libyaml-ruby
# apt-get install libzlib-ruby
# gem install rails

There’s probably more; e.g. activerecord and all but that’s enough for today. I shall get Subversion up and running soon too, so this can become my development platform.

Adapted from railsforum.com.