首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >rails 6应用程序测试绿色,但在生产中有奇怪的效果: LoadError (无法加载这样的文件-- rb-readline)

rails 6应用程序测试绿色,但在生产中有奇怪的效果: LoadError (无法加载这样的文件-- rb-readline)
EN

Stack Overflow用户
提问于 2019-11-25 17:40:13
回答 1查看 326关注 0票数 0

部署一个经过绿色测试的rails 6应用程序。

当然,在部署之后,预计生产中的行为与生产中的行为相同。

但是,在生产环境中,启动时会失败,并显示以下结果:

代码语言:javascript
复制
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中:

代码语言:javascript
复制
$ grep rb-readline Gemfile.lock
    rb-readline (0.5.5)
  rb-readline

所需的顺序为:

代码语言:javascript
复制
require 'pp'
require 'thor'
require 'ostruct'
require 'colorize'
require './config/environment'

require 'ta_thor'
require 'rb-readline'
require 'history_cache'
require 'grumples_module'

开发模式没有问题。仅在生产模式下失败。

生产环境总结:

代码语言:javascript
复制
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输出为:

代码语言:javascript
复制
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]

我还是被难住了。

EN

回答 1

Stack Overflow用户

发布于 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版本。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59028869

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档