Search code examples
rubybyebug

Byebug does not update local variable on Ubuntu


Here's my code:

# please_just_work.rb
require 'bundler/setup'
Bundler.require

byebug
puts "a = #{a}"

Inside the byebug session I set the value of a, but it remains undefined:

[1, 5] in /home/paper/tmp/debug.rb
   1: require 'bundler/setup'
   2: Bundler.require
   3: 
   4: byebug
=> 5: puts "a = #{a}"
(byebug) a = 1
1
(byebug) continue
Traceback (most recent call last):
please_just_work.rb:5:in `<main>': undefined local variable or method `a' for main:Object (NameError)

I'm running Ubuntu 18.04


Solution

  • Turns out I had to use @a instead of a. I did not find this in the documentation, so I'll leave the answer here for whoever faces this same issue.