rails: Rails console fails to start due to LoadError on trying to require irb
Steps to reproduce
Create a new rails project and run rails console
or bin/rails console
in the project.
Expected behavior
The rails console starts successfully.
Actual behavior
Rails immediately crashes with the following:
/usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require': cannot load such file -- irb (LoadError)
Did you mean? erb
drb
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:89:in `register'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:44:in `require'
from /usr/lib/ruby/gems/3.0.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34:in `require'
from /usr/lib/ruby/gems/3.0.0/gems/railties-6.1.3.2/lib/rails/commands/console/console_command.rb:3:in `<main>'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
from /usr/lib/ruby/gems/3.0.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34:in `require'
from /usr/lib/ruby/gems/3.0.0/gems/railties-6.1.3.2/lib/rails/command/behavior.rb:44:in `block (2 levels) in lookup'
from /usr/lib/ruby/gems/3.0.0/gems/railties-6.1.3.2/lib/rails/command/behavior.rb:40:in `each'
from /usr/lib/ruby/gems/3.0.0/gems/railties-6.1.3.2/lib/rails/command/behavior.rb:40:in `block in lookup'
from /usr/lib/ruby/gems/3.0.0/gems/railties-6.1.3.2/lib/rails/command/behavior.rb:39:in `each'
from /usr/lib/ruby/gems/3.0.0/gems/railties-6.1.3.2/lib/rails/command/behavior.rb:39:in `lookup'
from /usr/lib/ruby/gems/3.0.0/gems/railties-6.1.3.2/lib/rails/command.rb:76:in `find_by_namespace'
from /usr/lib/ruby/gems/3.0.0/gems/railties-6.1.3.2/lib/rails/command.rb:48:in `invoke'
from /usr/lib/ruby/gems/3.0.0/gems/railties-6.1.3.2/lib/rails/commands.rb:18:in `<main>'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
from /usr/lib/ruby/gems/3.0.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34:in `require'
from /home/cameron/OtherProjects/mykanban/bin/rails:5:in `<main>'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:59:in `load'
from /usr/lib/ruby/gems/3.0.0/gems/bootsnap-1.7.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:59:in `load'
from /usr/lib/ruby/gems/3.0.0/gems/activesupport-6.1.3.2/lib/active_support/fork_tracker.rb:10:in `block in fork'
from /usr/lib/ruby/gems/3.0.0/gems/activesupport-6.1.3.2/lib/active_support/fork_tracker.rb:10:in `block in fork'
from /usr/lib/ruby/gems/3.0.0/gems/activesupport-6.1.3.2/lib/active_support/fork_tracker.rb:8:in `fork'
from /usr/lib/ruby/gems/3.0.0/gems/activesupport-6.1.3.2/lib/active_support/fork_tracker.rb:8:in `fork'
from /usr/lib/ruby/gems/3.0.0/gems/activesupport-6.1.3.2/lib/active_support/fork_tracker.rb:26:in `fork'
from /usr/lib/ruby/gems/3.0.0/gems/activesupport-6.1.3.2/lib/active_support/fork_tracker.rb:8:in `fork'
from /usr/lib/ruby/gems/3.0.0/gems/activesupport-6.1.3.2/lib/active_support/fork_tracker.rb:26:in `fork'
from <internal:/usr/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from <internal:/usr/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from -e:1:in `<main>'
System configuration
Any x86-64 Arch Linux install with ruby and ruby-irb installed through pacman, and rails installed globally through gem. Note, it is possible to require irb normally outside of rails. Rails version: Rails 6.1.3.2 Ruby version: ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x86_64-linux]
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 21 (17 by maintainers)
Adding
gem 'irb'
to your Gemfile also fixes the problem - for some reason on Arch the gem isn’t in the default set of gems, e.g:vs.
I suspect this is a packaging thing in Arch but we should probably make sure before closing otherwise we may need to add
irb
torailties.gemspec
if it’s not going to be included in the default gems in future.The rationale behind splitting
irb
fromruby
distribution is that irb development moved to a separate repository. And ruby distribution is in a weird state right now. From one side they shipirb
as a part of default gemset. From other side if a CEV happens then ruby developers suggest to updateirb
as a standalone gem usingrubygems
.default gemset and stanalone gems use different locations. Arch packaging manager does not handle such either/or conditions. So we’ve moved to using
irb
(and some other components) as standalone gems exclusively.My suggestion is to add
gem irb'
to your Gemfile. It is a future-proof solution in case if ruby community decides to de-coupleirb
completely (which I would vote for).I was able to reproduce this:
in the container:
Same Error:
I also tried making a plain ruby script that requires irb to make sure irb existed and that worked fine:
Same error with
bootsnap/setup
removed:Closing this since it isn’t caused by Rails.
Can confirm that does indeed solve the problem and irb loads correctly after adding it.
hmm, very confusing. I haven’t found a combination of
GEM_HOME
andGEM_PATH
that finds the irb pacman installs.Is it safe to say the best advice for this situation is to use a ruby manager like
rbenv
,rvm
orchruby
?Probably this. Just tried with rvm and worked. The ruby installed by pacman, does not includes ‘irb’…
pacman install:
rvm install:
update: the ruby installed by pacman [https://archlinux.org/packages/extra/x86_64/ruby/], installs a package named ‘ruby-irb’