33

I have a project I'm trying to use ruby 3 (previously running with 2.7.2), but couldn't accomplish it.

After updated my gemfile with the ruby version and ran bundle, I'm receiving this error when trying to access rails c:

/home/rwehresmann/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.5.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require': cannot load such file -- webrick/httputils (LoadError)

I already tried to add webrick gem to see what happens, and the result is that rails c get stuck.

Here is my gemfile:

source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '3.0.0'

gem 'rails', '~> 6.0.1'
gem 'pg', '>= 0.18', '< 2.0'
gem 'puma', ">= 4.3.3"

gem 'aws-sdk-s3', '~> 1'
gem 'http', '~> 4.3.0'
gem 'redis', '~> 4.1.3'
gem 'jwt', '~> 2.2.1'
gem 'pundit', '~> 2.1.0'
gem 'blueprinter', '~> 0.23.0'
gem 'money-rails', '~> 1.13.3'
gem 'dry-struct', '~> 1.3.0'
gem 'sidekiq', '~> 6.0.5'
gem 'sidekiq-scheduler', '~> 3.0.1'
gem 'friendly_id', '~> 5.2.4'
gem 'holidays', '~> 8.4.1'
gem 'administrate', '~> 0.14.0'
gem 'administrate-field-enum', '~> 0.0.9'
gem 'pg_search', '~> 2.3.2'
gem 'ransack', '~> 2.3.2'
gem 'administrate-field-active_storage', '0.3.4'
gem 'image_processing', '~> 1.2'
gem 'rolify', '~> 5.3.0'
gem 'active_storage_validations', '~> 0.8.7'
gem 'audited', '~> 4.9'
gem 'slack-ruby-client', '~> 0.15.0'
gem 'inky-rb', require: 'inky'
# Stylesheet inlining for email
gem 'premailer-rails'

# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.4.2', require: false

# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible
gem 'rack-cors'

group :development, :test do
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
  gem 'rspec-rails', '~> 3.8.3'
  gem 'factory_bot_rails', '~> 5.1.1'
  gem 'capybara', '~> 3.31.0'
end

group :development do
  gem 'listen', '~> 3.4'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
  gem 'letter_opener'
end

group :test do
  gem 'shoulda-matchers', '~> 4.2.0'
  gem 'webmock', '~> 3.8.2'
end

Any suggestions?

6
  • You have spring in your gemfile, usually hanging consoles and servers are related to that. Try adding the webrick gem back into your gemfile, do a bundle install, and then run bin/spring stop. Then try re-running the console. Let me know if that works for you and I'll add it as an answer. Jan 7, 2021 at 18:45
  • 3
    You've already resolved the title of this question and original error: webrick was removed from the standard library in ruby 3. So yes, you need to install it as a gem.
    – Tom Lord
    Jan 7, 2021 at 19:08
  • As for why running rails "gets stuck", I don't know, you haven't provided any further context. As suggested above, try restarting it fully. If it's still failing, check for any log message, and post all information you have available.
    – Tom Lord
    Jan 7, 2021 at 19:09
  • @taylorthurlow it worked. However, I need to repeat this "stop process" every time I quit the console. Weird. Jan 7, 2021 at 23:36
  • @TomLord no log is provided. It just gets stuck and I need to close and reopen my terminal. Spring issues, like @taylorthurlow mentioned above. About webrick, it looks like is used with bootsnap gem, however, if I rails new a project the default gemfile includes bootsnap and it works perfectly without adding webrick in my gemfile. Jan 7, 2021 at 23:44

2 Answers 2

44

Try:

bundle add webrick

Adding gem "webrick" to Gemfile solves the problem.

1
  • 5
    Absolutely correct and short answer. Dec 11, 2021 at 10:12
40

You have spring in your gemfile, usually hanging consoles and servers are related to that. The webrick gem was removed from the standard library in Ruby 3, so that's why it needs to be included in your Gemfile.

Add webrick to your Gemfile, do a bundle install, and then stop the background spring server with bin/spring stop. Then re-run the server.

Your best bet on solving issues with spring would be to head over and read about the gem on the GitHub project page, or opening a new question here on SO.

1
  • 6
    It might be good to check which gem is relying on webrick instead of adding it as an additional dependency to the project. Looking at the gemfile in the original question it seems likely that the aws-sdk-s3 gem is the culprit, so updating that gem, if possible, may be a better solution. See the aws-sdk-s3 commit that removed their webrick dependency Jan 12, 2021 at 11:15

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.