-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using the irb:rdbg console corrupts irb_history by duplicating entries #855
Comments
Sorry for the trouble. I've identified the cause and will open a PR this week. |
st0012
referenced
this issue
Jan 31, 2024
The issue (https://github.com/ruby/debug/issues/1064) is caused by a combination of factors: 1. When user starts an IRB session without a history file, the `@loaded_history_lines` ivar is not defined. 2. If the user then starts the `irb:rdbg` session, the history counter is not set, because the `@loaded_history_lines` is not defined. 3. Because `irb:rdbg` saves the history before passing Ruby expression to the debugger, it saves the history with duplicated lines. The number grows in exponential order. 4. When the user exits the `irb:rdbg` session, the history file could be bloated with duplicated lines. This commit fixes the issue by resetting the history counter even when `@loaded_history_lines` is not defined.
st0012
referenced
this issue
Jan 31, 2024
The issue (https://github.com/ruby/debug/issues/1064) is caused by a combination of factors: 1. When user starts an IRB session without a history file, the `@loaded_history_lines` ivar is not defined. 2. If the user then starts the `irb:rdbg` session, the history counter is not set, because the `@loaded_history_lines` is not defined. 3. Because `irb:rdbg` saves the history before passing Ruby expression to the debugger, it saves the history with duplicated lines. The number grows in exponential order. 4. When the user exits the `irb:rdbg` session, the history file could be bloated with duplicated lines. This commit fixes the issue by resetting the history counter even when `@loaded_history_lines` is not defined.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Your environment
ruby -v
: 3.2.2 (and 3.0.6p216)rdbg -v
: 1.9.1irb -v
: 1.11.1Describe the bug
Ruby history doesn't remember history when using irb:rdbg as reported in ruby/debug#1054 but additionally it seems to duplicate things going into the history. After a couple hundred or so commands the history file can have millions of lines. It appears that irb:rdbg is putting the entire session history into the file for each line typed.
To Reproduce
I entered irb:rdbg and ran some commands. The history file already has more entries than it should, while also exhibiting the behavior described in ruby/debug#1054 . Finally returning to vanilla IRB I can see my history is back (with repeated commands).
Shell Session:
Expected behavior
I expect that the history file would only see each command once. Instead it appears to save the new command along with the entire previous history.
Additional context
Just for fun I noticed this issue when my performance got so bad that I couldn't get an IRB prompt anymore, when I checked the line count it was over 24 million!!! I have had this gem installed for only a few days!
The text was updated successfully, but these errors were encountered: