部署一个经过绿色测试的 rails 6 应用程序。
当然,部署后生产中的预期行为与生产中的行为相同。
但是,在生产中,启动时失败,结果如下:
LoadError: cannot load such file -- rb-readline
[path]/shared/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:33:in `require'
[path]/shared/vendor/bundle/ruby/2.6.0/gems/zeitwerk-2.2.1/lib/zeitwerk/kernel.rb:23:in `require' [$PATH]/ta.rb:19:in `<top (required)>'
rb-readline 存在于 Gemfile 中:
$ grep rb-readline Gemfile.lock
rb-readline (0.5.5)
rb-readline
要求的顺序是:
require 'pp'
require 'thor'
require 'ostruct'
require 'colorize'
require './config/environment'
require 'ta_thor'
require 'rb-readline'
require 'history_cache'
require 'grumples_module'
开发模式没有问题。仅在生产模式下失败。
生产环境总结:
rake about
Rake: Load benchmark (in seconds)
user system total real
0.396619 0.084458 0.483907 ( 0.487172).
About your application's environment
Rails version 6.0.1
Ruby version ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-linux]
RubyGems version 3.0.3
Rack version 2.0.7
JavaScript Runtime mini_racer (V8)
Middleware ActionDispatch::HostAuthorization, Rack::Sendfile, ActionDispatch::Executor, ActiveSupport::Cache::Strategy::LocalCache::Middleware, Rack::Runtime, Rack::MethodOverride, ActionDispatch::RequestId, ActionDispatch::RemoteIp, Rails::Rack::Logger, ActionDispatch::ShowExceptions, ActionDispatch::DebugExceptions, ActionDispatch::ActionableExceptions, ActionDispatch::Callbacks, ActionDispatch::Cookies, ActionDispatch::Session::CookieStore, ActionDispatch::Flash, ActionDispatch::ContentSecurityPolicy::Middleware, Rack::Head, Rack::ConditionalGet, Rack::ETag, Rack::TempfileReaper, Warden::Manager, ExceptionNotification::Rack
Application root [path]
Environment production
Database adapter mysql2
Database schema version 20190213065900
我难住了。
生产 gem env 输出是:
RubyGems Environment:
- RUBYGEMS VERSION: 3.0.6
- RUBY VERSION: 2.6.5 (2019-10-01 patchlevel 114) [x86_64-linux]
- INSTALLATION DIRECTORY: [*** home dir ***]/.gem/ruby/2.6.5
- USER INSTALLATION DIRECTORY: [*** home dir ***]/.gem/ruby/2.6.0
- RUBY EXECUTABLE: [*** home dir ***]/.rubies/ruby-2.6.5/bin/ruby
- GIT EXECUTABLE: /usr/bin/git
- EXECUTABLE DIRECTORY: [*** home dir ***]/.gem/ruby/2.6.5/bin
- SPEC CACHE DIRECTORY: [*** home dir ***]/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: [*** home dir ***]/.rubies/ruby-2.6.5/etc
...
ruby -v
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-linux]
我仍然很难过。