I am trying to implement server deployment for my rails app using capistrano. I am doing it for the first time. Now, I am stuck at a NoMethodError . I am not able find the issue
My Gemfile contains the following gems
group :development do
gem 'capistrano', require: false
gem 'capistrano3-puma', require: false
gem 'capistrano-rails', require: false
gem 'capistrano-bundler', require: false
gem 'capistrano-rbenv', require: false
end
application.rb
require_relative 'boot'
require "rails"
# Pick the frameworks you want:
require "active_model/railtie"
require "active_job/railtie"
require "active_record/railtie"
require "active_storage/engine"
require "action_controller/railtie"
require "action_mailer/railtie"
require "action_view/railtie"
require "action_cable/engine"
require "sprockets/railtie"
# require "rails/test_unit/railtie"
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module Server
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 5.2
end
end
Now I am getting the following error when executing the command
cap production deploy
deploy:assets:precompile
01 $HOME/.rbenv/bin/rbenv exec bundle exec rake assets:precompile
01 (in /home/ruby-user/server)
01 rake aborted!
01 NoMethodError: private method `warn' called for nil:NilClass
01 /home/ruby-user/server/shared/bundle/ruby/2.5.0/gems/sprockets-rails-3.2.1/lib/sprockets/railtie.rb:170:in `build_environment'
01 /home/ruby-user/server/shared/bundle/ruby/2.5.0/gems/railties-5.2.0/lib/rails/railtie.rb:190:in `public_send'
01 /home/ruby-user/server/shared/bundle/ruby/2.5.0/gems/railties-5.2.0/lib/rails/railtie.rb:190:in `method_missing'
01 /home/ruby-user/server/shared/bundle/ruby/2.5.0/gems/sprockets-rails-3.2.1/lib/sprockets/rails/task.rb:21:in `environment'
01 /home/ruby-user/server/shared/bundle/ruby/2.5.0/gems/sprockets-3.7.1/lib/rake/sprocketstask.rb:42:in `cached'
01 /home/ruby-user/server/shared/bundle/ruby/2.5.0/gems/sprockets-rails-3.2.1/lib/sprockets/rails/task.rb:46:in `manifest'
01 /home/ruby-user/server/shared/bundle/ruby/2.5.0/gems/sprockets-3.7.1/lib/rake/sprocketstask.rb:143:in `with_logger'
01 /home/ruby-user/server/shared/bundle/ruby/2.5.0/gems/sprockets-rails-3.2.1/lib/sprockets/rails/task.rb:67:in `block (2 levels) in d…
01 /home/ruby-user/server/shared/bundle/ruby/2.5.0/gems/rake-12.3.1/exe/rake:27:in `<top (required)>'
01 /home/ruby-user/.rbenv/versions/2.5.0/bin/bundle:23:in `load'
01 /home/ruby-user/.rbenv/versions/2.5.0/bin/bundle:23:in `<main>'
01 Tasks: TOP => assets:precompile
01 (See full trace by running task with --trace)
170th line of /home/ruby-user/server/shared/bundle/ruby/2.5.0/gems/sprockets-rails-3.2.1/lib/sprockets/railtie.rb has the following statement
::Rails.logger.warn "Application uninitialized: Try calling YourApp::Application.initialize!"
Please help me to sort it out. Thank you
It looks like you have to set the Rails.logger.warn in your application. Try this out in the environment file
Rails.logger = Logger.new(STDOUT)
I got this error and it turns out that I included a duplicate of my config.ru inside of my config/ folder. When it is there, it doesn't have access to this variable so it throws that error; just delete the duplicate and it should work.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.