Installing MacVim with Ruby support and Command T on OSX Lion

When I set up my new Macbook Air recently, I ran into some unexpected problems setting up MacVim – mostly related to Ruby versions linked against MacVim and the Command T plugin. Here are some notes that might help you.

Note
In case you wonder: MacVim uses it own separate version of vim (installed here: /Applications/MacVim.app/Contents/MacOS/Vim), which is not linked against your own /user/local/bin/vim (or wherever your vim resides), which you or your package manager installed separately. The reason I’m mentioning this is that if you lack Ruby support in MacVim, compiling vim by hand won’t help, since MacVim doesn’t use it.

Howto

in my case:
$ ruby -v
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.0.1]

$ brew install macvim

* start MacVim with
$ mvim
run :version and make sure it lists +ruby (instead of -ruby)
test Ruby support by invoking
:ruby nil[]
which should return a NoMethodError

 

$ cd ~/.vim
$ git submodule add git://git.wincent.com/command-t.git bundle/command-t
$ git submodule init
$ git clone git://git.wincent.com/command-t.git bundle/command-t

$ cd ~/.vim/bundle/command-t
$ rake make

more details in section 4 “MANAGING USING PATHOGEN” of: https://github.com/wincent/Command-T/blob/master/doc/command-t.txt

  • create a symlink under Applications:
    $ ln -s /usr/local/Cellar/macvim/7.3-62/MacVim.app /Applications/MacVim.app 

    Troubleshooting

    1) Lacking Ruby support inside MacVim
    Symptom: Plugins written in Ruby, like Command T or Lusty Juggler, don’t work.
    Check: $ mvim –version or :version inside of MacVim should list “-ruby”, if your version lacks Ruby support (“+ruby” if it has Ruby support built in).
    Cause: This happens when your version of MacVim was compiled without the –enable-rubinterp flag. This usually happens when you install a binary off MacVim’s Google Code Project.
    Remedy: Best use Homebrew to install MacVim from source. Although the Homebrew command’s output does not explicitly list the –enable-rubyinterp flag, you should be fine and :version should list +ruby.

    2) Can’t compile MacVim or vim
    Cause: You probably didn’t install Xcode. Unfortunately you need proprietary Cocoa headers for MacVim, which are not included in this Kenneth Reitz’ GCC OSX installer (https://github.com/kennethreitz/osx-gcc-installer; cf. related problem: https://github.com/mxcl/homebrew/issues/7576).
    Remedy: Install the full Xcode package via Apple’s App Store. Make sure to check your Launchpad for download activity – it took me half an hour to figure out that the app store’s Install button was actually doing something and not broken.

    3) Command T complains about lacking C extensions
    Symptom: Command T doesn’t start and informs me about missing C extensions.
    Remedy: run rake make inside ~/.vim/bundle/command-t

    4) Command T causes SIGTERMS
    Symptom: After having compiled Command T’s C extensions, as soon as you try to invoke Command T inside MacVim, it causes the program to crash with a SIGTERM exception.
    Cause: Usually the reason for the SIGTERM is that your MacVim was compiled with a link to a different version of Ruby than Command T. However, I encountered the same problem when linking everything against system Ruby (1.8.7 in my case).
    Remedy: Be very careful about your RVM/rbenv settings and ensure the exact same version of Ruby is active when you compile MacVim (installing via Homebrew triggers a compilation process) or Command T. My issue was resolved by using Ruby 1.9.2 instead of system Ruby.

  • Resources

    “Birthday” gem for easy anniversaries handling

    While working on one of our client projects, I was asked to create a search for users’ birthdays. Instantly, I remembered what problems I had with it in the past, like taking care of not only finding the right dates by only day and month, but also, checking for birthdays today, any upcoming birthdays, or even just looking up user’s age based on that information.

    So, to never ever repeat that code again (and to keep the code DRY), I’ve decided to write a simple gem specifically for this stuff. And thus the birthday gem was born.

    Requirements

    The gem has been tested against Rails 3 (3.0.9) and Rails 2 (2.3.14), and depends on ActiveRecord and ActiveSupport (for inflections), making it a perfect fit for Rails. It is possible to use it outside Rails project, but you are required to use ActiveRecord as your ORM framework.

    The gem works with MySQL and PostgreSQL adapters, but you can write your own adapters, if you need to. If you do so, it would be good to fork the gem and add it there for everybody to use. :)

    So, how does it actually work?

    Handling birthdays wasn’t that easy before. Here’s what you have to do in your model:

    That’s all. This one line enables extra actions on the “birthday” field (of DATE or DATETIME types) in your database. For example from now on you can search for birthdays

    All these methods are essentially scopes, so you could also do something like:

    On top of that, you get convenience methods for single records, like getting the age:

    You can get any field to behave like this. For example, let’s say we want marriage anniversaries:

    And it’s done, from now on you have convenient scopes to search and handle anniversaries:

    Final words

    I’ve done this gem, because I never ever want to write this piece of code again, I’d rather spend my time on actually coding the important stuff in applications, than to fiddle around with dates and birthdays. Hope this gem will be of some use to you. If not, fork it, and patch it to your needs! :)

    Backlash @ Robot Unicorn Invasion Party 2011

    Backlash @ Robot Unicorn Invasion Party 2011 by Backslash on Mixcloud

    Help You need somebody; Help not just anybody!

    Here at Railslove, we love building web applications. But aside from our core business, we also help other startups understand how the web works and what it means to run a web business — in Hamburg, Berlin, Cologne. And since experienced Ruby on Rails developers are increasingly hard to find, we’ve started to offer apprenticeships, too.

    One of our new partners is DailyDeal. We’ve done some beginners and advanced courses in Rails covering stuff like testing, building APIs, advanced JavaScript coding and general design and programming patterns in Ruby on Rails, etc.

    Oliver Hepfner, Director Software Engineering of DailyDeal:

    The training Railslove provided under the direction of Georg Leciejewski helped us understand advanced programming patterns in Ruby on Rails. Our developers were excited to get a hands-on introduction into Ruby on Rails.

     

    Next month, we will launch a few more courses with DailyDeal and with other companies, like Adcloud GmbH in Germany. If you are interested in learning more, please contact Ralph and Georg: ralph AT railslove.com & gl AT salesking.eu & team AT railslove.com

    Travis – a distributed build system

    Let us introduce us to Travis. What is Travis? As you can read on Github:

    Travis is an attempt to create an open-source, distributed build system for the Ruby community that:

    1. allows open-source projects to register their repository and have their test-suites run on demand
    2. allows users to contribute build capacities by connecting a VM that runs a build agent somewhere on their underused servers

    Travis Logo You can and should use travis for your open source projects as an continuos integration system. Travis is an incredible project and helps increase the quality of  lots of Open Source projects. So please head over to travis and setup tests for your ruby, node.js, erlang, … projects. – you can also setup your own instance installing Travis and use it for your private projects.

    For more information check out the github page and the getting started section.

    We’re really happy to be able to support Travis by sponsoring one of the worker boxes.

    btw. Sven, Josh, thanks for mentioning us on your talks at Ruby Lugdunum and Frozen Rails 2011 this year. ;)

    Btw.: have you heard about the Awesome Bot Factory? With the Awesome Bot Factory you’re able to create bots for your campfire channel. There is a bot to integrate travis to your campfire chat: simply ask the bot for a given status, like:

    Jan travis:status Nerds/NerdPursuit
    Choco Bits Bot Nerds/NerdPursuit is stable

    Or get notified about your project’s new travis builds.

    - Thank you, Travis-CI!

    Resources: