Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7839369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:25:37+00:00 2026-06-02T15:25:37+00:00

Here is my ruby script: require_relative ‘lib/say.rb’ say(hello) I run it from macvim via

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T15:25:38+00:00Added an answer on June 2, 2026 at 3:25 pm

    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

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my script #!/usr/bin/env ruby if __FILE__ == $0 `cd ..` puts `ls`
The language is Ruby, here is my irb session expr = /\Aselect from (\D+)(?:
I am having a problem getting a Ruby script to work correctly when run
I am trying to pass an array to a ruby script from a command
I am trying to install ruby 1.9.2 from a ruby script using rvm which
This ruby script does not run. It responds with /Users/superhappyfuntime/Desktop/twt.rb:25: undefined local variable or
I have implemented Ruby C extension(i.e. Invoking C function from ruby script) Following is
environment.rb:7: uninitialized constant Rails::Initializer (NameError) from /usr/lib/ruby/gems/1.8/gems/railties-3.1.0/lib/rails/application.rb:78:in `require_environment!' from /usr/lib/ruby/gems/1.8/gems/railties-3.1.0/lib/rails/commands.rb:39 from script/rails:6:in `require' from
Since I've migrated from Leopard to Snow Leopard I get $ ruby script/server Rails
I have been looking at ways to program a UI in ruby here, on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.