首页 > 解决方案 > 无法加载此类文件 -- webrick/httputils

问题描述

我有一个项目我正在尝试使用 ruby​​ 3(以前使用 2.7.2 运行),但无法完成。

用 ruby​​ 版本更新我的 gemfile 并运行bundle后,我在尝试访问时收到此错误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)

我已经尝试添加 webrick gem 来看看会发生什么,结果是rails c卡住了。

这是我的宝石文件:

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

有什么建议么?

标签: ruby-on-railsrubybootsnapruby-3

解决方案


spring在 gemfile 中有通常挂起的控制台和服务器与此相关。gem 已从 Ruby 3的webrick标准库中删除,因此需要将其包含在 Gemfile 中。

添加webrick到您的 Gemfile,进行捆绑安装,然后使用bin/spring stop. 然后重新运行服务器。

解决 spring 问题的最佳选择是前往并阅读GitHub 项目页面上的 gem ,或者在 SO 上打开一个新问题。


推荐阅读