groovenauts / capistrano-systemd-multiservice

Capistrano Plugin to control services with systemd
MIT License
45 stars 17 forks source link

uninitialized constant Capistrano::Systemd::MultiService::SystemService::Rails #22

Closed alexandrule closed 3 years ago

alexandrule commented 3 years ago

Hello. Trying to understand where is the issue, when I'm running:

bundle exec cap production systemd:sidekiq1:setup

I'm getting the following error:

#<Thread:0x00007facbfa604a0 /Users/alex/.rvm/gems/ruby-2.7.1/gems/sshkit-1.21.0/lib/sshkit/runners/parallel.rb:10 run> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
    9: from /Users/alex/.rvm/gems/ruby-2.7.1/gems/sshkit-1.21.0/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
    8: from /Users/alex/.rvm/gems/ruby-2.7.1/gems/sshkit-1.21.0/lib/sshkit/backends/abstract.rb:31:in `run'
    7: from /Users/alex/.rvm/gems/ruby-2.7.1/gems/sshkit-1.21.0/lib/sshkit/backends/abstract.rb:31:in `instance_exec'
    6: from /Users/alex/.rvm/gems/ruby-2.7.1/gems/capistrano-systemd-multiservice-0.1.0.beta10/lib/capistrano/tasks/systemd/multiservice/system_service.rake:22:in `block (5 levels) in eval_rakefile'
    5: from /Users/alex/.rvm/gems/ruby-2.7.1/gems/capistrano-systemd-multiservice-0.1.0.beta10/lib/capistrano/systemd/multiservice/system_service.rb:79:in `setup'
    4: from /Users/alex/.rvm/gems/ruby-2.7.1/gems/capistrano-systemd-multiservice-0.1.0.beta10/lib/capistrano/systemd/multiservice/system_service.rb:79:in `each'
    3: from /Users/alex/.rvm/gems/ruby-2.7.1/gems/capistrano-systemd-multiservice-0.1.0.beta10/lib/capistrano/systemd/multiservice/system_service.rb:80:in `block in setup'
    2: from /Users/alex/.rvm/rubies/ruby-2.7.1/lib/ruby/2.7.0/erb.rb:905:in `result'
    1: from /Users/alex/.rvm/rubies/ruby-2.7.1/lib/ruby/2.7.0/erb.rb:905:in `eval'
(erb):43:in `block in setup': uninitialized constant Capistrano::Systemd::MultiService::SystemService::Rails (NameError)
    1: from /Users/alex/.rvm/gems/ruby-2.7.1/gems/sshkit-1.21.0/lib/sshkit/runners/parallel.rb:11:in `block (2 levels) in execute'
/Users/alex/.rvm/gems/ruby-2.7.1/gems/sshkit-1.21.0/lib/sshkit/runners/parallel.rb:15:in `rescue in block (2 levels) in execute': Exception while executing as ubuntu@*.*.*.*: uninitialized constant Capistrano::Systemd::MultiService::SystemService::Rails (SSHKit::Runner::ExecuteError)

Gemfile

ruby '2.7.1'
gem 'rails', '~> 6.0.3'
gem 'capistrano', '~> 3.14', '>= 3.14.1'
gem 'capistrano-systemd-multiservice', '~> 0.1.0.beta10'

Capfile

require 'capistrano/systemd/multiservice'
install_plugin Capistrano::Systemd::MultiService.new_service('sidekiq1', service_type: 'system')

Interesting that this works in rails 4.2 and ruby 2.3.3.

minimum2scp commented 3 years ago

It seems that your erb file contains something like <%= Rails.xxx %> or <%= Rails::Xxx %>, isn't it?

Please try to add :: before Rails, like this: <%= ::Rails.xxx %>, <%= ::Rails::Xxx %>.

alexandrule commented 3 years ago

@minimum2scp Thank you for support. Was the problem with <%= Rails.env.production? %> I solved it by changing to <%= fetch(:rails_env) == 'production' %> <%= ::Rails.env.production? %> doesn't work.