Capistrano 3.7.2,Rails 5.0.2和Ruby 2.4.0是特定的。使用Rails 5,Ruby 2.4和Capistrano 3在Capistrano部署期間發送電子郵件3
** Execute load:defaults
cap aborted!
NameError: uninitialized constant ActiveSupport::Rescuable
/Users/username/.rvm/gems/ruby-2.4.0/gems/actionmailer-5.0.2/lib/action_mailer/rescuable.rb:6:in `<module:Rescuable>'
/Users/username/.rvm/gems/ruby-2.4.0/gems/actionmailer-5.0.2/lib/action_mailer/rescuable.rb:4:in `<module:ActionMailer>'
/Users/username/.rvm/gems/ruby-2.4.0/gems/actionmailer-5.0.2/lib/action_mailer/rescuable.rb:1:in `<top (required)>'
/Users/username/.rvm/gems/ruby-2.4.0/gems/actionmailer-5.0.2/lib/action_mailer/base.rb:8:in `require'
/Users/username/.rvm/gems/ruby-2.4.0/gems/actionmailer-5.0.2/lib/action_mailer/base.rb:8:in `<top (required)>'
/Users/username/rails_5_test_app/config/deploy/notify/cap_mailer.rb:5:in `require'
/Users/username/rails_5_test_app/config/deploy/notify/cap_mailer.rb:5:in `<top (required)>'
config/deploy.rb:4:in `require'
config/deploy.rb:4:in `<top (required)>'
/Users/username/.rvm/gems/ruby-2.4.0/gems/capistrano-3.7.2/lib/capistrano/setup.rb:27:in `load'
/Users/username/.rvm/gems/ruby-2.4.0/gems/capistrano-3.7.2/lib/capistrano/setup.rb:27:in `block (3 levels) in <top (required)>'
/Users/username/.rvm/gems/ruby-2.4.0/gems/capistrano-3.7.2/lib/capistrano/configuration/variables.rb:32:in `untrusted!'
/Users/username/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/delegate.rb:83:in `method_missing'
/Users/username/.rvm/gems/ruby-2.4.0/gems/capistrano-3.7.2/lib/capistrano/setup.rb:26:in `block (2 levels) in <top (required)>'
/Users/username/.rvm/gems/[email protected]/gems/rake-12.0.0/lib/rake/task.rb:250:in `block in execute'
/Users/username/.rvm/gems/[email protected]/gems/rake-12.0.0/lib/rake/task.rb:250:in `each'
/Users/username/.rvm/gems/[email protected]/gems/rake-12.0.0/lib/rake/task.rb:250:in `execute'
/Users/username/.rvm/gems/[email protected]/gems/rake-12.0.0/lib/rake/task.rb:194:in `block in invoke_with_call_chain'
/Users/username/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/monitor.rb:214:in `mon_synchronize'
/Users/username/.rvm/gems/[email protected]/gems/rake-12.0.0/lib/rake/task.rb:187:in `invoke_with_call_chain'
/Users/username/.rvm/gems/[email protected]/gems/rake-12.0.0/lib/rake/task.rb:180:in `invoke'
/Users/username/.rvm/gems/[email protected]/gems/rake-12.0.0/lib/rake/application.rb:152:in `invoke_task'
/Users/username/.rvm/gems/[email protected]/gems/rake-12.0.0/lib/rake/application.rb:108:in `block (2 levels) in top_level'
/Users/username/.rvm/gems/[email protected]/gems/rake-12.0.0/lib/rake/application.rb:108:in `each'
/Users/username/.rvm/gems/[email protected]/gems/rake-12.0.0/lib/rake/application.rb:108:in `block in top_level'
/Users/username/.rvm/gems/[email protected]/gems/rake-12.0.0/lib/rake/application.rb:117:in `run_with_threads'
/Users/username/.rvm/gems/[email protected]/gems/rake-12.0.0/lib/rake/application.rb:102:in `top_level'
/Users/username/.rvm/gems/[email protected]/gems/rake-12.0.0/lib/rake/application.rb:80:in `block in run'
/Users/username/.rvm/gems/[email protected]/gems/rake-12.0.0/lib/rake/application.rb:178:in `standard_exception_handling'
/Users/username/.rvm/gems/[email protected]/gems/rake-12.0.0/lib/rake/application.rb:77:in `run'
/Users/username/.rvm/gems/ruby-2.4.0/gems/capistrano-3.7.2/lib/capistrano/application.rb:14:in `run'
/Users/username/.rvm/gems/ruby-2.4.0/gems/capistrano-3.7.2/bin/cap:3:in `<top (required)>'
/Users/username/.rvm/gems/ruby-2.4.0/bin/cap:22:in `load'
/Users/username/.rvm/gems/ruby-2.4.0/bin/cap:22:in `<main>'
/Users/username/.rvm/gems/ruby-2.4.0/bin/ruby_executable_hooks:15:in `eval'
/Users/username/.rvm/gems/ruby-2.4.0/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => staging
我即將開始升級我的Rails應用4到Rails 5,並決定做一個小的測試應用程序,以確保我所有的寶石都工作:Execute load:defaults
後,我得到的錯誤發生。一切都很好,除了自從Rails 2在Capistrano部署期間發送電子郵件以來我一直使用的代碼之外,當我嘗試要求或加載郵件程序代碼時導致此錯誤; deploy.rb的第4行是要求。如果我對此發表評論並設置標誌不發送電子郵件,則部署工作完美。
的郵件代碼(基於關閉的東西通過MislavMarohnić年發佈前):
cap_mailer.rb:
require "action_mailer"
yaml_config = File.read("config/email.yml")
email_config = YAML.load(yaml_config)
ActionMailer::Base.delivery_method = email_config['delivery_method'] # currently set to :smtp
ActionMailer::Base.smtp_settings = {
address: email_config['smtp_settings']['address'],
port: email_config['smtp_settings']['port'],
notify_emails: email_config['notify_emails']
}
ActionMailer::Base.view_paths = File.dirname(__FILE__)
class CapMailer < ActionMailer::Base
default :from => 'App Deployment <[email protected]>'
def deploy_notification(cap_vars)
@now = Time.now
set :body, ENV['comment']
mail(:to => fetch(:notify_emails),
:subject => "#{fetch(:human_readable_application_name)} - Changes to application on #{fetch(:stage)} server at #{fetch(:host)}"
)
end
def test_email
@now = Time.now
mail(:to => "[email protected]",
:subject => "#{fetch(:human_readable_application_name)} - Capistrano test email #{@now.strftime("on %m/%d/%Y at %I:%M %p")}"
)
end
end
我能挖網上都引用非常類似的郵件設置窗口(例如https://gist.github.com/johnthethird/955917),它們是針對所有事情的舊版本編寫的。在卡皮斯特拉諾部署期間,有幾封寶石用於發送郵件,但它們與真的很舊(capistrano-notifier,capistrano_mailer)的問題相同。
所以在這一點上我卡住了。谷歌搜索NameError: uninitialized constant ActiveSupport::Rescuable
建議也許這是一個配置問題,但我不知道該找什麼。在我的Rails安裝中有ActiveSupport :: Rescuable IS;我仔細檢查。任何想法,將不勝感激。
那完美。你能解釋爲什麼這是必要的嗎?和/或爲什麼只有在Rails 5中才有必要?我以前沒有遇到過這樣的事情。 – Maltiriel
好吧,根據錯誤,ActionMailer依賴於'ActiveSupport :: Rescuable',但它顯然不會自己加載它。這看起來像是ActionMailer 5.0.2的一個監督(bug),我會在Rails GitHub上報告它。 –