Here is my ruby script:
require_relative 'lib/say.rb'
say("hello")
I run it from macvim via :w ! ruby and got:
:w ! ruby
-:1:in `require_relative': cannot infer basepath (LoadError)
from -:1:in `<main>'
shell returned 1
Though ! ruby % vim command works fine.
And also changing the require_relative... to require File.expand_path('../lib/say', __FILE__) also helps…
But… What is actually wrong with these friends: require_relative + :w ! ruby ?
Why do I need this? Just to use in vim the ⌘ + R shortkey from the vim-ruby-runner plugin which is based on :w !ruby vim command and have my code looks better with require_relative…
P.S.
I found the following question on SO: Why isn't current directory on my Ruby path?
Seems the latter source correspond to my problem too… But it was hard for me to get all answers I need from there.
The owner of the vim-ruby-runner plugin, found the solution at http://www.rodrigoalvesvieira.com/add-require-relative-to-irb/
Plugin is fixed and can be get at https://github.com/henrik/vim-ruby-runner
Solution (and fix for vim-ruby-runner) can be also found at https://github.com/henrik/vim-ruby-runner/issues/5