ruby-on-rails - 更新的引导 gem 无法加载到 rails
问题描述
Bootstrap 曾经在 Rails 上运行得非常好!现在我遇到了一个非常奇怪的错误。
我之前使用的是旧版本的 Bootstrap gem(如果我没记错的话,它是 4.1.3)。然而,当我推送我的 rails 应用程序时,Github 给了我这个令人担忧的警告:
在 4.3.1 之前的 Bootstrap 4 和 3.4.1 之前的 Bootstrap 3 中,工具提示或弹出框数据模板属性中可能存在 XSS。有关更多信息,请参阅: https ://blog.getbootstrap.com/2019/02/13/bootstrap-4-3-1-and-3-4-1/
明白了,我想它会发生。现在要做的合乎逻辑的事情是更新我的 gemfile,以便引导 gem 依赖语句如下所示:
gem "bootstrap", ">= 4.3.1"
很容易。添加后,运行bundle install
并重新启动服务器后,出现此错误:
/Users/myusername/.rvm/gems/ruby-2.5.1/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require': cannot load such file -- bootstrap (LoadError)
很奇怪吧?我实际上在两种不同的情况下遇到了这个错误:
- 我有一个 Rails 引擎,它也依赖于引导程序,我在我的应用程序中用作 gem。每当我尝试将最新版本的引导 gem 添加为依赖项时,都会收到此错误。
- 在将引导程序添加到我的 gemfile 时,我也会遇到此错误,就像使用任何常规 gem 和应用程序一样。
我该如何解决这个错误?任何帮助表示赞赏!
这是我的完整堆栈跟踪
Traceback (most recent call last):
59: from bin/rails:3:in `<main>'
58: from bin/rails:3:in `load'
57: from /Users/angelgarcia/Documents/Dev/websites/search-analysis-tool/bin/spring:15:in `<top (required)>'
56: from /Users/angelgarcia/.rvm/rubies/ruby-2.5.1/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:65:in `require'
55: from /Users/angelgarcia/.rvm/rubies/ruby-2.5.1/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:65:in `require'
54: from /Users/angelgarcia/.rvm/gems/ruby-2.5.1/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `<top (required)>'
53: from /Users/angelgarcia/.rvm/gems/ruby-2.5.1/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load'
52: from /Users/angelgarcia/.rvm/gems/ruby-2.5.1/gems/spring-2.0.2/bin/spring:49:in `<top (required)>'
51: from /Users/angelgarcia/.rvm/gems/ruby-2.5.1/gems/spring-2.0.2/lib/spring/client.rb:30:in `run'
50: from /Users/angelgarcia/.rvm/gems/ruby-2.5.1/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call'
49: from /Users/angelgarcia/.rvm/gems/ruby-2.5.1/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `call'
48: from /Users/angelgarcia/.rvm/gems/ruby-2.5.1/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load'
47: from /Users/angelgarcia/Documents/Dev/websites/search-analysis-tool/bin/rails:9:in `<top (required)>'
46: from /Users/angelgarcia/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require'
45: from /Users/angelgarcia/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency'
44: from /Users/angelgarcia/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `block in require'
43: from /Users/angelgarcia/.rvm/gems/ruby-2.5.1/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
42: from /Users/angelgarcia/.rvm/gems/ruby-2.5.1/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
41: from /Users/angelgarcia/.rvm/gems/ruby-2.5.1/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
40: from /Users/angelgarcia/.rvm/gems/ruby-2.5.1/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
39: from /Users/angelgarcia/.rvm/gems/ruby-2.5.1/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
38: from /Users/angelgarcia/.rvm/gems/ruby-2.5.1/gems/railties-5.2.3/lib/rails/commands.rb:18:in `<top (required)>'
37: from /Users/angelgarcia/.rvm/gems/ruby-2.5.1/gems/railties-5.2.3/lib/rails/command.rb:46:in `invoke'
36: from /Users/angelgarcia/.rvm/gems/ruby-2.5.1/gems/railties-5.2.3/lib/rails/command/base.rb:65:in `perform'
35: from /Users/angelgarcia/.rvm/gems/ruby-2.5.1/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
34: from /Users/angelgarcia/.rvm/gems/ruby-2.5.1/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
33: from /Users/angelgarcia/.rvm/gems/ruby-2.5.1/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
32: from /Users/angelgarcia/.rvm/gems/ruby-2.5.1/gems/railties-5.2.3/lib/rails/commands/server/server_command.rb:142:in `perform'
31: from /Users/angelgarcia/.rvm/gems/ruby-2.5.1/gems/railties-5.2.3/lib/rails/commands/server/server_command.rb:142:in `tap'
30: from /Users/angelgarcia/.rvm/gems/ruby-2.5.1/gems/railties-5.2.3/lib/rails/commands/server/server_command.rb:145:in `block in perform'
29: from /Users/angelgarcia/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require'
28: from /Users/angelgarcia/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency'
27: from /Users/angelgarcia/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `block in require'
26: from /Users/angelgarcia/.rvm/gems/ruby-2.5.1/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
25: from /Users/angelgarcia/.rvm/gems/ruby-2.5.1/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
24: from /Users/angelgarcia/.rvm/gems/ruby-2.5.1/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
23: from /Users/angelgarcia/.rvm/gems/ruby-2.5.1/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
22: from /Users/angelgarcia/.rvm/gems/ruby-2.5.1/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
21: from /Users/angelgarcia/Documents/Dev/websites/search-analysis-tool/config/application.rb:7:in `<top (required)>'
20: from /Users/angelgarcia/.rvm/rubies/ruby-2.5.1/lib/ruby/site_ruby/2.5.0/bundler.rb:114:in `require'
19: from /Users/angelgarcia/.rvm/rubies/ruby-2.5.1/lib/ruby/site_ruby/2.5.0/bundler/runtime.rb:65:in `require'
18: from /Users/angelgarcia/.rvm/rubies/ruby-2.5.1/lib/ruby/site_ruby/2.5.0/bundler/runtime.rb:65:in `each'
17: from /Users/angelgarcia/.rvm/rubies/ruby-2.5.1/lib/ruby/site_ruby/2.5.0/bundler/runtime.rb:76:in `block in require'
16: from /Users/angelgarcia/.rvm/rubies/ruby-2.5.1/lib/ruby/site_ruby/2.5.0/bundler/runtime.rb:76:in `each'
15: from /Users/angelgarcia/.rvm/rubies/ruby-2.5.1/lib/ruby/site_ruby/2.5.0/bundler/runtime.rb:81:in `block (2 levels) in require'
14: from /Users/angelgarcia/.rvm/gems/ruby-2.5.1/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
13: from /Users/angelgarcia/.rvm/gems/ruby-2.5.1/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
12: from /Users/angelgarcia/.rvm/gems/ruby-2.5.1/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
11: from /Users/angelgarcia/.rvm/gems/ruby-2.5.1/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
10: from /Users/angelgarcia/.rvm/gems/ruby-2.5.1/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
9: from /Users/angelgarcia/.rvm/gems/ruby-2.5.1/bundler/gems/elko-engine-f7b39674f535/lib/elko.rb:5:in `<top (required)>'
8: from /Users/angelgarcia/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require'
7: from /Users/angelgarcia/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency'
6: from /Users/angelgarcia/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `block in require'
5: from /Users/angelgarcia/.rvm/gems/ruby-2.5.1/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:26:in `require'
4: from /Users/angelgarcia/.rvm/gems/ruby-2.5.1/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:40:in `rescue in require'
3: from /Users/angelgarcia/.rvm/gems/ruby-2.5.1/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
2: from /Users/angelgarcia/.rvm/gems/ruby-2.5.1/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/loaded_features_index.rb:89:in `register'
1: from /Users/angelgarcia/.rvm/gems/ruby-2.5.1/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
/Users/angelgarcia/.rvm/gems/ruby-2.5.1/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require': cannot load such file -- bootstrap (LoadError)
解决方案
看起来有问题bootsnap gem
。尝试删除其缓存
rm -rf tmp/cache/bootsnap*
推荐阅读
- c++ - 将 fwrite 转换为 C++ 类型代码以写入二进制文件
- xpath - 为什么我的 XPath 和 HTML 抓取在 Google 表格中停止工作?
- html - 如何在纵向和横向视图之间保持 HTML 按钮的纵横比?
- regex - 使用 vars 或在 /regex/.test 中重复
- python - 使用“upload_file”在 AWS S3 中上传 csv 在 S3 中获取 0 字节
- javascript - 重新连接后套接字发射不起作用
- firebase - 使用 Firebase 云功能向用户发送通知时未定义的字段
- c# - 在同一控制器的操作中映射到模型和从模型映射
- node.js - 如何使用 docker 中的卷同步 node.js 工作区更改
- asp.net-core - 只在 Scrutor 中直接继承接口的类注册接口