# Scripting vim using ruby interface

**URL:** <https://www.ruby-forum.com/t/scripting-vim-using-ruby-interface/127238>\
**Category:** Ruby\
**Created:** [January 26, 2008, 8:24pm UTC](https://www.ruby-forum.com/t/scripting-vim-using-ruby-interface/127238 "2008-01-26T20:24:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![crocco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/fbc32d/32.png) [@crocco](https://www.ruby-forum.com/u/crocco)\
**Post date:** [January 26, 2008, 8:24pm UTC](https://www.ruby-forum.com/t/scripting-vim-using-ruby-interface/127238/1 "2008-01-26T20:24:04Z")

</div>

I know this should be posted to the vim mailing list, but I wasn’t able  
to  
subscribe to it, so I’m posting here instead.

I’ve been trying to write a vim script using vim’s ruby interface, but I  
keep  
coming across weird errors in completely unexpected places. A very  
simple  
example is the following: I give the following command (all in one line,  
of  
course):

:ruby require ‘pathname’;  
Pathname.new(’/home/stefano/Desktop/test\_tools/’).realpath

This command, which works perfectly when executed in irb or using ruby  
-e or  
from a ruby script, when called from vim gives an error:

SystemStackError: /usr/lib/ruby/1.8/pathname.rb:266:in `chop\_basename’:  
stack  
level too deep.

Moreover, these errors seem random: I can run a piece of code once and  
it  
works; i run it again later and it gives an error like the above one  
(it’s  
always a SystemStackError). Yet, every time this happens, it’s always in  
the  
same position.

Does anyone know if there’s a reason for this behaviour, such as some  
kind of  
restriction to the ruby code you can call in ruby? Has anyone succeeded  
in  
using ruby interface? I’ve searched google, the vim mailing list and vim  
documentation, but I found nothing.

Thanks in advance

Stefano
