0

Specifically, I see:

Loading development environment (Rails 4.2.1)
irb(main):001:0> f
NameError: undefined local variable or method `f' for main:Object
from (irb):1
from /Users/benjamin/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands/console.rb:110:in `start'
from /Users/benjamin/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands/console.rb:9:in `start'
from /Users/benjamin/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:68:in `console'
from /Users/benjamin/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /Users/benjamin/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/railties-4.2.1/lib/rails/commands.rb:17:in `<top (required)>'
from /Users/benjamin/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `require'
from /Users/benjamin/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `block in require'
from /Users/benjamin/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:240:in `load_dependency'
from /Users/benjamin/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:274:in `require'
from /Users/benjamin/demo/bin/rails:8:in `<top (required)>'
from /Users/benjamin/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:268:in `load'
from /Users/benjamin/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:268:in `block in load'
from /Users/benjamin/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:240:in `load_dependency'
from /Users/benjamin/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/activesupport-4.2.1/lib/active_support/dependencies.rb:268:in `load'
from /Users/benjamin/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/spring-1.3.3/lib/spring/commands/rails.rb:6:in `call'
from /Users/benjamin/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/spring-1.3.3/lib/spring/command_wrapper.rb:38:in `call'
from /Users/benjamin/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/spring-1.3.3/lib/spring/application.rb:183:in `block in serve'
from /Users/benjamin/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/spring-1.3.3/lib/spring/application.rb:156:in `fork'
from /Users/benjamin/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/spring-1.3.3/lib/spring/application.rb:156:in `serve'
from /Users/benjamin/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/spring-1.3.3/lib/spring/application.rb:131:in `block in run'
from /Users/benjamin/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/spring-1.3.3/lib/spring/application.rb:125:in `loop'
from /Users/benjamin/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/spring-1.3.3/lib/spring/application.rb:125:in `run'
from /Users/benjamin/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/spring-1.3.3/lib/spring/application/boot.rb:18:in `<top (required)>'
from /Users/benjamin/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/benjamin/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'

How can I hide these permanently and just see the actual error message? I've found a few things online that show how to termporarily hide these line items including:

IRB.CurrentContext.back_trace_limit = 0

But nothing permanent yet.

Appreciate the help!

Ben

Ben
  • 71
  • 1
  • 9

1 Answers1

0

The extra lines are the "backtrace" as you've correctly identified from your current context call.

I think you need to add .irbrc file as described here. This would typically be in your home directory although it will use the .irbrc file in your current directory if the home directory does not contain one.

In that file you can add a line to limit the size of the backtrace each time you call irb or rails console:

IRB.conf[:BACK_TRACE_LIMIT] = 0

You might not want to reduce it to zero as it does sometimes give clues as to where an error might be originating if the error message itself is not particularly helpful.

Shadwell
  • 34,314
  • 14
  • 94
  • 99