I'm having various issues with my Rails console under JRuby, including
^[[A
or ^[[B
gets inserted, respectively)^[[D
or ^[[C
gets inserted, respectively)1~
or 4~
inserted, respectively); Ctrl+a / Ctrl+e work thoughI installed my JRuby interpreter from rvm like so:
rvm install jruby-1.6.8 --1.9
My Rails project is managed using Bundler (not rvm gemsets), so I run my Rails console using bundle exec rails c
. Interestingly, raw irb
as well as bundle exec irb
don't have most of the above issues, except the Home/End keys and Ctrl+c needs an Enter before I get a fresh prompt line.
I can replicate the issue with a barebones Rails Gemfile
:
source 'https://rubygems.org'
gem 'rails', '3.2.6'
gem 'sqlite3'
My shell is zsh
, on Ubuntu 12.04 64-bit. $JAVA_HOME
is /usr/lib/jvm/java-7-openjdk-amd64
, but it might have still been java-6 when I installed this interpreter, if that matters.
Update: Some fixes
The missing prompt character is apparently caused by the IRB.conf[:PROMPT_MODE]
getting set to :NULL
by the Rails console. For regular irb
, mine gets set to :RVM
(apparently rvm does this in ~/.rvm/scripts/irb.rb
; I ruled out rvm causing this issue by commenting out the script). Providing a :PROMPT_MODE
value in ~/.irbrc
fixes this. I thought maybe a similar issue was causing the Ctrl+c / Ctrl+d problems by changing :IGNORE_SIGINT
and :IGNORE_EOF
, but they are both set to their default values.
Tab completion and arrow keys get fixed by setting :USE_READLINE
to true.
Here's my current ~/.irbrc
that seems to fix said issues:
require 'irb/completion'
IRB.conf[:PROMPT_MODE] = :SIMPLE
IRB.conf[:USE_READLINE] = true
IRB.conf[:AUTO_INDENT] = true
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With