Skip to content

Having require "irb/ext/history" and IRB.conf[:EVAL_HISTORY]= in .irbrc causes error #804

Closed

Description

@knu

Description

If you have these lines in your .irbrc, irb dies with the following error.

require "irb/ext/history"
IRB.conf[:EVAL_HISTORY] = 100
% irb
/home/knu/.local/share/rtx/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.10.1/lib/irb/workspace.rb:117:in `eval': no implicit conversion of IRB::Context into String (TypeError)

      eval(statements, @binding, file, line)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        from /home/knu/.local/share/rtx/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.10.1/lib/irb/workspace.rb:117:in `evaluate'
        from /home/knu/.local/share/rtx/installs/ruby/3.2.2/lib/ruby/3.2.0/irb/ext/history.rb:58:in `eval_history='
        from /home/knu/.local/share/rtx/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.10.1/lib/irb/context.rb:66:in `initialize'
        from /home/knu/.local/share/rtx/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.10.1/lib/irb.rb:428:in `new'
        from /home/knu/.local/share/rtx/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.10.1/lib/irb.rb:428:in `initialize'
        from /home/knu/.local/share/rtx/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.10.1/lib/irb.rb:394:in `new'
        from /home/knu/.local/share/rtx/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.10.1/lib/irb.rb:394:in `start'
        from /home/knu/.local/share/rtx/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.10.1/exe/irb:9:in `<top (required)>'
        from /home/knu/.local/share/rtx/installs/ruby/3.2.2/bin/irb:25:in `load'
        from /home/knu/.local/share/rtx/installs/ruby/3.2.2/bin/irb:25:in `<main>'

The above .irbrc works with irb 1.6.x, but any later version I tested failed. I haven't bisected, but starting from 1.7.2, I guess? -- #623

Result of irb_info

irb(main):001> irb_info
Ruby version: 3.2.2
IRB version: irb 1.10.1 (2023-12-05)
InputMethod: RelineInputMethod with Reline 0.4.1 and /home/knu/.inputrc
Completion: Autocomplete, RegexpCompletor
.irbrc path: /home/knu/.irbrc
RUBY_PLATFORM: x86_64-linux
LANG env: ja_JP.UTF-8
East Asian Ambiguous Width: 2

Terminal Emulator

iTerm

Setting Files

Activity

  1. knu commented on Dec 6, 2023

    @knu
    MemberAuthor

    I know I can just omit the require and the problem is gone, but I've filed this anyway because the error was so unexpected.

  2. changed the title [-]Having `require "irb/ext/history` and `IRB.conf[:EVAL_HISTORY]=` in .irbrc causes error[/-] [+]Having `require "irb/ext/history"` and `IRB.conf[:EVAL_HISTORY]=` in .irbrc causes error[/+] on Dec 6, 2023
  3. tompng commented on Dec 6, 2023

    @tompng
    Member

    The file irb/ext/history does not exist anymore.

    In my environment, these two require requires a file from different IRB version.

    require 'irb/ext/eval_history'
    # ~/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/irb-1.10.0/lib/irb/ext/eval_history.rb
    require 'irb/ext/history'
    # ~/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb/ext/history.rb
  4. st0012 commented on Dec 6, 2023

    @st0012
    Member

    I'm sorry for the trouble. The require hasn't been needed for a long while (since as least IRB v0.9.6) as Context#eval_history would load it when IRB.conf[:EVAL_HISTORY] is set. So when I was implementing #623, I considered it as an implementation detail instead of a public component.

  5. knu commented on Dec 6, 2023

    @knu
    MemberAuthor

    Thank you both! So, the solution here is to just remove the require as I said and it'll work also for reasonably old versions of irb, correct?

  6. st0012 commented on Dec 6, 2023

    @st0012
    Member

    Yes. From my testing, it should work at least with IRB v1.2.0 without the require (can't test earlier due to other errors).

  7. knu commented on Dec 7, 2023

    @knu
    MemberAuthor

    Thanks for your investigation. It took me some time to figure out what was going on from the error output because nothing was found on Google, so I hope whoever encounters this problem in the future will find this issue and the solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions