部署一个经过绿色测试的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]我还是被难住了。
发布于 2019-11-25 17:52:32
似乎在dev和prod之间有一个不同的Ruby版本:- 2.6.5p114在开发中- 2.6.0在生产中。
也许gemfile.lock中的某个gem版本与2.6.0不兼容。
2个解决方案:如果你在dev中有rvm或rbenv,你可以在本地安装2.6.0,然后再次进行捆绑安装,也许可以通过使用gem版本来修复需要修复的问题。
或者,您可以在您的gemfile (而不是gemfile.lock):ruby '2.6.5'中添加一个ruby版本,希望您的生产环境能够支持这个Ruby版本。
https://stackoverflow.com/questions/59028869
复制相似问题