Search code examples
ruby-on-railsrubyrubygemsbundler

Cannot start Rails Console - cannot load such file "ext/save-history.rb"


I recently upgraded my Rails 7.0.4 Application from Ruby 2.7.5 to 3.2.2

Everything is working correctly - I can run the server, tests, etc - but I cannot start a Rails console. When I do start a console I get this error:

/Users/my-user-name/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require': cannot load such file -- /Users/my-user-name/src/ext/save-history.rb (LoadError)

I first thought that this is a Bootsnap error but when I comment out require 'bootsnap/setup' in my config/boot.rb I get a similar but different error:

/Users/my-user-name/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/dead_end-1.1.6/lib/dead_end/auto.rb:30:in `require': cannot load such file -- /Users/my-user-name/src/ext/save-history.rb (LoadError)
    from /Users/my-user-name/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/dead_end-1.1.6/lib/dead_end/auto.rb:30:in `require_relative'
    from /Users/my-user-name/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb/extend-command.rb:368:in `save_history='
    from /Users/my-user-name/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb/context.rb:137:in `initialize'
    from /Users/my-user-name/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb.rb:473:in `new'
    from /Users/my-user-name/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb.rb:473:in `initialize'
    from /Users/my-user-name/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb.rb:419:in `new'
    from /Users/my-user-name/.rbenv/versions/3.2.2/lib/ruby/3.2.0/irb.rb:419:in `start'
    from /Users/my-user-name/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.0.4/lib/rails/commands/console/console_command.rb:70:in `start'
    from /Users/my-user-name/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.0.4/lib/rails/commands/console/console_command.rb:19:in `start'
    from /Users/my-user-name/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.0.4/lib/rails/commands/console/console_command.rb:102:in `perform'
    from /Users/my-user-name/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
    from /Users/my-user-name/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
    from /Users/my-user-name/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
    from /Users/my-user-name/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.0.4/lib/rails/command/base.rb:87:in `perform'
    from /Users/my-user-name/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.0.4/lib/rails/command.rb:48:in `invoke'
    from /Users/my-user-name/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/railties-7.0.4/lib/rails/commands.rb:18:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'

This appears to somehow be an issue with the Irb session trying to load the library to save my Irb history? I've tried uninstalling ruby and re-installing, re-installing all gems with bundler, nothing seems to change.

I can't tell what the problem is though - is this a ruby issue, a bundler issue, an issue with one of the gems, and OSX issue?

I am using

  1. RBenv 1.2.0
  2. Ruby 3.2.2
  3. Bundler 2.3.20
  4. Rubygems 3.4.10
  5. Rails 7.0.4

Worth noting that I deploy to Heroku and I can start a Heroku console without any issues.


Solution

  • Dead_end -> syntax_suggest

    Quite likely this will be a red herring but you can try migrating off of dead_end gem.

    dead_end gem has been renamed to syntax_suggest and is a default gem in ruby3.2. See the readme section for renaming. Try upgrading it to see if it helps.

    Try adding irb to your Gemfile

    The mentioned file has been deleted in this pr, and on the version irb 1.7.2. Upgrading your irb might fix your issue.

    gem 'irb', '~> 1.4'
    

    bundle install

    Apart from this can fix your issue, it will also benefit you since irb gets regular improvements while waiting to be included in the next ruby release.

    If you are still seeing the same error

    You might want to add these details to your question

    • Are you using a config file like ~/.irbrc
    • Have you tried running spring stop
    • Link your installed gems as a text file like a github gist