Magnus Skjegstad

Getting funnel.pl to work in OS X

There are several plugins for Vim and MacVim that require a connection to an external program such as R, Lisp or Octave. Some of them rely on a Perl-script written by Larry Clapp called funnel.pl to communicate with the external program. Unfortunately, this script can be difficult to get to work in OS X as it depends on the GNU Readline library.

Before you use this guide you should follow the instructions for the plugin you want to configure (e.g. for R, Lisp or Octave). At some point the instructions will tell you to start funnel.pl and it will fail with an error message like

Can't locate object method "initialize" via package 
"Term::ReadLine::Stub" at ./funnel.pl line 404.

To fix this, first make sure you have IO::Pty installed from CPAN:

sudo cpan install IO::Pty

Next, we need to install GNU Readline. If you use Homebrew it can be installed with

brew install readline

Homebrew does not install the library system wide, as that would be in potential conflict with libedit, the library normally used in OS X. Instead, it places it in a subdirectory in your Homebrew directory structure. On my machine, this was /usr/local/homebrew/Cellar/readline/6.2.2. If you are unsure you can use the command

brew info readline

to see where it was installed.

Finally, we need to install Term::ReadLine::Gnu and link it to the GNU Readline library. You should be able to find the latest version here. I used version 1.20.

Extract the source code and run

perl Makefile.PL \
    --includedir=/usr/local/homebrew/Cellar/readline/6.2.2/include/ \
    --libdir=/usr/local/homebrew/Cellar/readline/6.2.2/lib/

Change the libdir and includedir options so that they reflect the location of the readline-library installed by Homebrew.

You should now be able to compile and install the Term::ReadLine::Gnu module using

make && \
sudo make install

After compilation succeeds and the module is installed you should be able to run funnel.pl.

vim