1

Deploying a rails 6 app which has tested green.

Expected same behaviour in production after deployment as in production, of course.

However, in production, when starting, fails with the following result:

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 exists in the Gemfile:

$ grep rb-readline Gemfile.lock
    rb-readline (0.5.5)
  rb-readline

The require sequence is:

require 'pp'
require 'thor'
require 'ostruct'
require 'colorize'
require './config/environment'

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

There are no issues in development mode. Only fails in production mode.

Production enviroment summary:

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

I'm stumped.

The production gem env output is:

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]

and I'm still stumped.

willyab
  • 167
  • 1
  • 10
  • Set `config.eager_load = true` in development.rb to test in local – Rajdeep Singh Nov 25 '19 at 09:50
  • That was already set. I've also commented out the bootsnap require (in boot.rb) because it appears to add so much to start up time. – willyab Nov 26 '19 at 10:15
  • Maybe you haven't properly configured your server? if on ubuntu try `sudo apt-get install libreadline-dev` There maybe other libraries you also need to setup such as libdev etc... so I suggest you go through your server setup and check that everythong needed has been installed properly – jamesc Nov 26 '19 at 11:58

1 Answers1

1

It seems there is a different Ruby version beetween dev and prod: - 2.6.5p114 in development - 2.6.0 in production.

Maybe a version of some gem in gemfile.lock is not compatible with 2.6.0.

2 solutions : If you have rvm or rbenv in dev, you can install 2.6.0 locally and do a bundle install again and maybe fix what is needed to be fixed by playing with gems versions.

Alternatively you can add a ruby version in your gemfile (not gemfile.lock) : ruby '2.6.5' hoping that your production environment can serve this Ruby version.

Maxence
  • 2,029
  • 4
  • 18
  • 37
  • Gemfile specifies ruby '2.6.5'. I think the 2.6.0 directory is correct though and as it should be. I use chruby rather than rvm or rbenv. .ruby-version specifies ruby-2.6.5. So I am pretty confident the ruby version between development/production is consistent. On checking the gem env output between the dev environment and the production environment I can confirm they are identical save for the path names. – willyab Nov 26 '19 at 10:14
  • The best way to know is to open a bash on your production environment and check directly the Ruby version `ruby -v`. If it shows indeed 2.6.0 then change the Ruby version in your gemfile, install Ruby 2.6.0 locally, and do a bundle install. You can also kill the gemfile.lock and do the bundle install. But if some gems are not versionned in your gemfile, you may get a newer version (which can be a problem with gems like `wkhtmltopdf` which will break the PDF styling) – Maxence Nov 26 '19 at 10:33
  • added the gem env output for production. Also, the directory [*** home dir ***]/.gem/ruby/2.6.0 is empty. Ran the ruby -v to show ruby version. – willyab Nov 26 '19 at 11:24