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 6227299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:11:24+00:00 2026-05-24T09:11:24+00:00

Recently I saw Gary Bernhardt show off a vim shortcut he uses to execute

  • 0

Recently I saw Gary Bernhardt show off a vim shortcut he uses to execute Ruby code from within vim. The shortcut is

:map ,t :w\|:!ruby %<cr>.  

It seems that this method always execute’s the System Ruby, which in my case is 1.8.7. I’m hesitant to upgrade this as I’ve heard that changing the System Ruby interpreter can cause some wonky issues. Is there anyway to get this command to use the version setup for the directory with RVM?

  • 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-05-24T09:11:25+00:00Added an answer on May 24, 2026 at 9:11 am

    The most direct way to specify a ruby is to give its full pathname in the :! command (instead of relying on whichever ruby is found first in the PATH directories):

    • To use the Ruby at /path/to/your/preferred/ruby:

      :!/path/to/your/preferred/ruby %
      
    • To use RVM-installed ruby-1.9.2-head:

      :!~/.rvm/bin/ruby-1.9.2-head %
      
    • To use RVM-installed ruby-1.9.2-head with your rails3-dev gemset:

      :!~/.rvm/bin/ruby-1.9.2-head@rails3-dev %
      

    So your map command might end up like this:

    :map ,t :w\|:!~/.rvm/bin/ruby-1.9.2-head@rails3-dev %<cr>
    

    It is also usually possible to adjust the effective value of the PATH environment variable so that your desired ruby is the first one found, but it may not always be as simple as you might like. Specifically, the :! commands are processed by the shell configured by the shell Vim option (:set shell? to see its value). The configuration files for that shell may modify the PATH value that Vim gives the shell (compare Vim’s PATH (:echo $PATH) to the PATH that :! commands end up using (:!echo $PATH) to see if your shell’s configuration files might be adjusting the PATH).

    You might try modifying the PATH that Vim and its children use like this:

    :let $PATH = $HOME . '/.rvm/wrappers/ruby-1.9.2-head@rails3-dev:' . $PATH
    

    You should check the effective PATH with :!echo $PATH and :!which ruby to find whether your shell is further modifying the PATH (maybe :set shell=/bin/sh if you have this problem).

    Note: I have never seen this particular use of RVM’s wrapper directories, future versions of RVM may break it. The normal usage is to create a wrapper and invoke it directly out of ~/.rvm/bin (similar to the first part of this post) instead of putting ~/.rvm/wrapper/whatever in the PATH.

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

Sidebar

Related Questions

I recently saw some code from a college teacher where he had something like
I recently saw a bit of code that looked like this (with sock being
I recently saw someone with a T-shirt with some Perl code on the back.
I recently saw code that looks like this: (function (someGlobal) { someGlobal.DoSomething(); })(someGlobal); where
I recently saw a blog post showing off different displays that some software development
I recently saw some code that reminded me to ask this question. Lately, I've
I recently saw this code on another post ( jQuery Set Cursor Position in
I recently saw some VIM configuration where search matches would scroll to N lines
Recently I saw a lot of similiar code chunks in one project, which were
I saw recently following code: #define MY_ASSERT_CONCAT_(a, b) a##b #define MY_ASSERT_CONCAT(a, b) MY_ASSERT_CONCAT_(a, b)

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.