I posted this in IRC earlier but I thought I’d ask a larger audience:

(01:39:01 PM) avdi: So here’s my problem
(01:39:55 PM) avdi: My emacs is set up to run various Ruby/Rails-related commands within projects, e.g. “rake cucumber”, as a result of keypresses
(01:40:17 PM) avdi: However, when it runs these, it is invoking system() directly – no shell intermediary
(01:40:37 PM) avdi: Which means no directory-specific RVM environment
(01:40:52 PM) avdi: which means it pukes because there’s no system-wide rake command defined
(01:41:54 PM) avdi: I suspect this is a common problem. Is there a common solution? Basically I want to set up system-wide standard ruby commands (like rake) which delegate intelligently to the correct RVM configuration based on working directory.
(01:42:32 PM) avdi: I suppose I could write a shell script called “rake” which loaded RVM and then called rake
(01:42:56 PM) avdi: Just wondering if there were any shortcuts provided by RVM for this sort of thing.

Anyone else run into this need? Any solutions?

UPDATE: Josh Miller pointed me to a solution, at least for Emacs: use rvm.el. Works like a charm.

Published by Avdi Grimm


  1. Creating wrapper scripts similar to http://rvm.beginrescueend.com/…/ should work.

  2. This may also be a solution, but I'm not that familiar with emacs: https://github.com/senny/rvm.e

  3. How about creating one or more RVM wrapper scripts, and configuring emacs to execute them? Run “rvm wrapper” or “rvm -h | less -p wrapper” for more info.

    • This doesn't really solve my problem, since the last thing I want to do is go through every single extension that calls some ruby command – ruby, rake, ri, cucumber, rcov, rdebug, etc. and modify the extension or the configuration so it calls a wrapper script. Also, according to the meager “rvm wrapper”docs, it doesn't create “smart” proxies that pick an implementation based on the .rvmrc in your working directory. It creates wrappers which are bound to a specific version and gemset.

      Any workable solution needs to be fairly general and not require a massive reconfiguration every time I switch projects. So far, rvm.el seems like the best solution, since it actually does a setenv call in Emacs to modify the RVM-related environment variables, which then is “magically” picked up by any commands Emacs executes.


Leave a Reply

Your email address will not be published. Required fields are marked *