inf-ruby provides a REPL buffer connected to a Ruby subprocess.
package.el is the built-in package manager in Emacs 24+. On Emacs 23
you will need to get package.el yourself if you wish to use it.
And then you can install
inf-ruby with the following command:
M-x package-install [RET] inf-ruby [RET]
or by adding this bit of Emacs Lisp code to your Emacs initialization file (
(unless (package-installed-p 'inf-ruby) (package-install 'inf-ruby))
If the installation doesn't work try refreshing the package list:
M-x package-refresh-contents [RET]
el-get is another popular package manager for Emacs. If you're an el-get user just do M-x el-get-install.
If you're installing manually, you'll need to:
- drop the
inf-ruby.elfile somewhere on your load path (perhaps
- Add the following lines to your
(autoload 'inf-ruby-minor-mode "inf-ruby" "Run an inferior Ruby process" t) (add-hook 'ruby-mode-hook 'inf-ruby-minor-mode)
Or, for enh-ruby-mode:
(add-hook 'enh-ruby-mode-hook 'inf-ruby-minor-mode)
package.el interface does the above for you
Additionally, consider adding
(add-hook 'compilation-filter-hook 'inf-ruby-auto-enter)
to your init file to automatically switch from common Ruby compilation modes to interact with a debugger.
If you wish to add other interpreter prompt patterns, see the description in the wiki.
inf-ruby comes bundled in
Emacs Prelude. If you're a
Prelude user you can start using it right away.
A simple IRB process can be fired up with M-x inf-ruby.
To launch a REPL with project-specific console instead, type M-x inf-ruby-console-auto.
It recognizes several project types, including Rails, gems and anything with
racksh in their Gemfile.
When entered, this mode runs
inf-ruby-mode-hook (in that order).
ruby-switch-to-infswitches the current buffer to the ruby process buffer.
ruby-send-definitionsends the current definition to the ruby process.
ruby-send-regionsends the current region to the ruby process.
ruby-send-region-and-goswitch to the ruby process buffer after sending their text.
- RET after the end of the process' output sends the text from the end of process to point.
- RET before the end of the process' output copies the sexp ending at point to the end of the process' output, and sends it.
- DEL converts tabs to spaces as it moves back.
- TAB completes the input at point. IRB, Pry and Bond completion is supported.
- C-M-q does TAB on each line starting within following expression.
- Paragraphs are separated only by blank lines.
- If you accidentally suspend your process, use
comint-continue-subjobto continue it.
To see the list of the keybindings defined by
type M-x describe-function [RET] inf-ruby-minor-mode [RET].
- If there is a triangle instead of prompt, or you see a reline related error, or your REPL simply doesn't react to input, try putting the following in your
IRB.conf[:USE_MULTILINE] = false if ENV['INSIDE_EMACS'] IRB.conf[:USE_READLINE] = false if ENV['INSIDE_EMACS']
For most projects that
inf-ruby-console-auto can recognize, we try
to apply this flag automatically (using command line arguments rather
.irbrc), but some cases remain where the users will have to do
Pry raises ZeroDivisionError in
Pry.config.pager = false if ENV["INSIDE_EMACS"]into your
�[0Gright after start?
Pry.config.correct_indent = false if ENV["INSIDE_EMACS"]into your
Please report problems at http://github.com/nonsequitur/inf-ruby/issues.