不确定到底是什么原因或如何开始的,但是突然在本地环境上运行良好的应用程序不再起作用。
我的本地开发环境是: MacOS Sierra 10.12.5
应用使用:
每当我运行rails或rails c时,应用程序就会启动并立即崩溃,并显示以下输出:
➜ pwf-site git:(master) ✗ rails c
Traceback (most recent call last):
67: from bin/rails:4:in `<main>'
66: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in `require'
65: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:257:in `load_dependency'
64: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in `block in require'
63: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
62: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
61: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'
60: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
59: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
58: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/commands.rb:18:in `<main>'
57: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/command.rb:46:in `invoke'
56: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/command/base.rb:65:in `perform'
55: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
54: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
53: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
52: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/commands/console/console_command.rb:95:in `perform'
51: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/command/actions.rb:18:in `require_application_and_environment!'
50: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/application.rb:337:in `require_environment!'
49: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in `require'
48: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:257:in `load_dependency'
47: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in `block in require'
46: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
45: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
44: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'
43: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
42: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
41: from /Users/herbyraynaud/code/personal/pwf-site/config/environment.rb:5:in `<main>'
40: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/application.rb:361:in `initialize!'
39: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/initializable.rb:60:in `run_initializers'
38: from /Users/herbyraynaud/.rbenv/versions/2.5.0/lib/ruby/2.5.0/tsort.rb:205:in `tsort_each'
37: from /Users/herbyraynaud/.rbenv/versions/2.5.0/lib/ruby/2.5.0/tsort.rb:226:in `tsort_each'
36: from /Users/herbyraynaud/.rbenv/versions/2.5.0/lib/ruby/2.5.0/tsort.rb:347:in `each_strongly_connected_component'
35: from /Users/herbyraynaud/.rbenv/versions/2.5.0/lib/ruby/2.5.0/tsort.rb:347:in `call'
34: from /Users/herbyraynaud/.rbenv/versions/2.5.0/lib/ruby/2.5.0/tsort.rb:347:in `each'
33: from /Users/herbyraynaud/.rbenv/versions/2.5.0/lib/ruby/2.5.0/tsort.rb:349:in `block in each_strongly_connected_component'
32: from /Users/herbyraynaud/.rbenv/versions/2.5.0/lib/ruby/2.5.0/tsort.rb:431:in `each_strongly_connected_component_from'
31: from /Users/herbyraynaud/.rbenv/versions/2.5.0/lib/ruby/2.5.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
30: from /Users/herbyraynaud/.rbenv/versions/2.5.0/lib/ruby/2.5.0/tsort.rb:228:in `block in tsort_each'
29: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/initializable.rb:61:in `block in run_initializers'
28: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/initializable.rb:32:in `run'
27: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/initializable.rb:32:in `instance_exec'
26: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/application/finisher.rb:130:in `block in <module:Finisher>'
25: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/application/routes_reloader.rb:10:in `execute'
24: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/file_update_checker.rb:83:in `execute'
23: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/application/routes_reloader.rb:30:in `block in updater'
22: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/application/routes_reloader.rb:20:in `reload!'
21: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/application/routes_reloader.rb:41:in `load_paths'
20: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/application/routes_reloader.rb:41:in `each'
19: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/application/routes_reloader.rb:41:in `block in load_paths'
18: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:285:in `load'
17: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:257:in `load_dependency'
16: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:285:in `block in load'
15: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:50:in `load'
14: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:50:in `load'
13: from /Users/herbyraynaud/code/personal/pwf-site/config/routes.rb:1:in `<main>'
12: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in `require'
11: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:257:in `load_dependency'
10: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in `block in require'
9: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
8: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
7: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'
6: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
5: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
4: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/sidekiq-5.2.5/lib/sidekiq/web.rb:13:in `<main>'
3: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in `require'
2: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:257:in `load_dependency'
1: from /Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in `block in require'
/Users/herbyraynaud/code/personal/pwf-site/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require': cannot load such file -- rack/protection (LoadError)
机架保护 gem是 Sinatra 的一部分,因此我尝试将 sinatra 添加到Gemfile并进行常规的gem安装但看起来像是一条红鲱鱼。
这是我尝试过的各种组合和命令的东西,没有任何缝隙可以工作
也有类似的问题表明问题与引导程序gem有关,但事实证明它们是红鲱鱼,删除了该宝石并在boot.rb文件中禁用了引导程序并不能解决问题。
最后,除了解决sqlite3版本问题外,我还可以创建一个新的Rails应用程序,我可以毫无问题地运行服务器和控制台。
这使我相信该问题一定是某些gem依赖导致问题的原因。
这是一个总的抓头。
这是我的宝石文件
source 'https://rubygems.org'
ruby "2.5.0"
gem 'rails', '5.2.2'
gem 'bootsnap'
gem 'devise'
gem "simple_form"
gem 'simple_enum', git: 'git://github.com/lwe/simple_enum.git'
gem 'kaminari'
gem 'activerecord-import'
gem 'font-awesome-sass', '~> 5.2.0'
gem 'pg'
gem 'puma', '~> 3.7'
gem 'activeadmin'
gem 'activeadmin_blaze_theme'
gem 'inherited_resources'
gem 'stripe'
gem "aws-sdk-s3", require: false
gem "image_processing", "~> 1.2"
gem "prawn"#, :git => "git://github.com/prawnpdf/prawn.git"
gem 'prawn-table' #, '~> 0.1.0'
gem "bootstrap", ">= 4.3.1"
gem 'jquery-rails'
gem "chosen-rails"
gem 'rails-observers'
gem 'combine_pdf'
gem 'figaro'
gem 'exception_handler'
gem "chartkick"
gem 'activeadmin_medium_editor', git: "git://github.com/hraynaud/activeadmin_medium_editor.git"
gem 'sidekiq'
group :development, :test do
gem "better_errors"
gem "hirb"
gem 'rspec'
gem "rspec-rails"
gem 'factory_bot'
gem "factory_bot_rails"
gem "faker"
gem "populator"
gem "pry"
gem "pry-nav"
gem "fakeweb", git: "https://github.com/chrisk/fakeweb.git"
gem "letter_opener"
end
group :test do
gem 'capybara'
gem "guard-rspec"
gem "rspec-activemodel-mocks"
gem "database_cleaner"
gem "launchy"
gem 'simplecov', :require => false
gem 'selenium-webdriver'
gem 'chromedriver-helper'
end
答案 0 :(得分:1)
当然,经过将近一整天的时间来弄清楚这一点并最终发布到SO。 SO帖子上升5分钟后,我想出了解决方案。
我没有尝试过的一件事就是移动线路:
gem bootsnap
至稍后在Gemfile中所有默认gem下方,但在开发和测试组之前。完成此操作后,Rails服务器和Rails控制台突然又开始工作。
奇怪的是,我想确认这确实是问题所在,所以我撤消更改,删除了 tmp / cache 中的引导缓存,删除了我的vendor / bundle目录并重新执行了捆绑安装,效果很好。即使它已被破坏了将近2天。好像暂时将bootsnap向下移动到其他宝石下面,从而使卡住的东西不再粘滞。奇怪的是,甚至没有从我的应用程序中完全删除引导快照也能够使它再次正常工作,而只是将其临时移动到Gemfile的底部就可以了吗?
所以我比以往任何时候都更困惑,但至少它再次起作用。
答案 1 :(得分:0)
我有一个类似的问题可以解决。
使用rbenv将ruby版本从2.3.4升级到2.5.1。安装捆绑程序1.17.3,运行bundle install
。一切都安装正确,但是由于引导缓存,我的rails控制台一直使用较旧的宝石,而不会加载新安装的宝石。
轨道c成功启动,但是调用require {gem_name}
导致路径丢失错误(如下)。 Bundler路径,gem env,gem列表等,其他所有内容都是正确的。
[5] pry(main)> require 'simple_enum'
LoadError: cannot load such file -- simple_enum
from /Users/max/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
最后清除了tmp / cache文件夹,捆绑了更新的引导快照,一切正常!
答案 2 :(得分:0)
在卸载我的 ruby 2.6.6
并使用 rbenv
重新安装后,我遇到了类似的问题。运行 bundle
后 rails console
不起作用。
/Users/jmschp/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require': cannot load such file -- /Users/jmschp/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/e2mmap-0.1.0/lib/e2mmap.rb (LoadError)
为我解决问题的是运行 rails tmp:clear
。