Foreman-rake console lacks usability

When firing up the foreman console, i get the following output

# foreman-rake console
/usr/share/foreman/lib/foreman.rb:8: warning: already initialized constant Foreman::UUID_REGEXP
/usr/share/foreman/lib/foreman.rb:8: warning: previous definition of UUID_REGEXP was here
/usr/share/foreman/lib/core_extensions.rb:182: warning: already initialized constant ActiveSupport::MessageEncryptor::DEFAULT_CIPHER
/opt/theforeman/tfm-ror51/root/usr/share/gems/gems/activesupport-5.1.6/lib/active_support/message_encryptor.rb:22: warning: previous definition of DEFAULT_CIPHER was here
Loading production environment (Rails 5.1.6)
Failed to load console gems, starting anyway

and then the irb is quite bad regarding usability.
The three things that com to my mind are

  • history is not preserved accross sessions
  • arrowup history destroys the last output if that was multiline
  • tab completion might work in rare cases, but most of the time it segfaults the whole shell

Expected outcome:
A shiny, fast and usable interactive ruby shell.
Either no tab completion, or one that does not kill the session.

Foreman and Proxy versions:
All, i know of.

I was recommended to run pry within the irb as a workaround. It helped.

I have a few useful gems in my Gemfile.local.rb file that change my console to use pry, with a few nice extras making debugging easier:

gem 'pry-rails' # this causes rails c to launch pry instead of irb
gem 'pry-byebug' # allows stepping in breakpoints
gem 'pry-doc' # gives easy access to ruby/rails docs in the console
gem 'pry-stack_explorer' # allows going up and down the call stack

Perhaps it’s worth adding some of them to the default console.rb bundle file?

1 Like