Fist of Senn

a developer's notebook

Use the Right Ruby With Emacs and Rbenv

I recently switched from rvm to rbenv to solve some annoying problems related to rvm. The switch was really painless and after half an hour I was operating again. Next up was integrating rbenv with Emacs.

simple configuration

If you only want to use the global Ruby you configured with rbenv simply add the following lines to your Emacs configuration:

;; Setting rbenv path
(setenv "PATH" (concat (getenv "HOME") "/.rbenv/shims:" (getenv "HOME") "/.rbenv/bin:" (getenv "PATH")))
(setq exec-path (cons (concat (getenv "HOME") "/.rbenv/shims") (cons (concat (getenv "HOME") "/.rbenv/bin") exec-path)))

described by Marc Bowes Using rbenv with Emacs


Back with rvm I wrote an elisp package called rvm.el to make it easy to switch between Ruby versions. I’ve engrained to be able to switch rubies inside Emacs and I wanted to be able to do the same thing with rbenv.

Happily integrating rbenv is very simple and switching the Ruby version is as easy as setting the RBENV_VERSION environment variable. I bundled my configuration to an elisp package and thus rbenv.el was born.

The library currently supports:

  • rbenv-use-global: activate your global ruby
  • rbenv-use: allows you to choose what ruby version you want to activate
  • rbenv-use-corresponding: searches for .ruby-version or .rbenv-version and activates the corresponding ruby

Note that rbenv.el always configures the complete Emacs session. There is no way to set the Ruby version on a per buffer basis.


Like most elisp packages you can simply download the source from github, add it to the load-path and require ‘rbenv. As an alternative I submitted the package to Marmalade, MELPA and opened a PR on el-get.

Take rbenv.el for a ride and let me know what you think!