Skip to content

Conversation

taketo1113
Copy link

This Pull Request fixes an error that occurs when running update-crontab on CentOS Stream 10, which prevents Capistrano deployments from completing.

The error is as follows:

$ bundle exec cap production whenever:update_crontab
00:00 whenever:update_crontab
      01 /usr/local/rbenv/bin/rbenv exec bundle exec whenever --update-crontab my-app_production --set environment=production --roles=web,app,db 
      01 bundler: failed to load command: whenever (/var/www/my-app-production/shared/bundle/ruby/3.4.0/bin/whenever)
      01 /var/www/my-app-production/shared/bundle/ruby/3.4.0/gems/whenever-1.0.0/lib/whenever/command_line.rb:82:in 'Whenever::CommandLine#write_crontab': undefined method 'zero?' for nil (NoMethodError)
      01
      01       success = $?.exitstatus.zero?
      01                              ^^^^^^
      01 	from /var/www/my-app-production/shared/bundle/ruby/3.4.0/gems/whenever-1.0.0/lib/whenever/command_line.rb:38:in 'Whenever::CommandLine#run'
      01 	from /var/www/my-app-production/shared/bundle/ruby/3.4.0/gems/whenever-1.0.0/lib/whenever/command_line.rb:6:in 'Whenever::CommandLine.execute'
      01 	from /var/www/my-app-production/shared/bundle/ruby/3.4.0/gems/whenever-1.0.0/bin/whenever:44:in '<top (required)>'
      01 	from /var/www/my-app-production/shared/bundle/ruby/3.4.0/bin/whenever:25:in 'Kernel#load'
      01 	from /var/www/my-app-production/shared/bundle/ruby/3.4.0/bin/whenever:25:in '<top (required)>'
      01 	from /usr/local/rbenv/versions/3.4.6/lib/ruby/3.4.0/bundler/cli/exec.rb:59:in 'Kernel.load'
      01 	from /usr/local/rbenv/versions/3.4.6/lib/ruby/3.4.0/bundler/cli/exec.rb:59:in 'Bundler::CLI::Exec#kernel_load'
      01 	from /usr/local/rbenv/versions/3.4.6/lib/ruby/3.4.0/bundler/cli/exec.rb:23:in 'Bundler::CLI::Exec#run'
      01 	from /usr/local/rbenv/versions/3.4.6/lib/ruby/3.4.0/bundler/cli.rb:452:in 'Bundler::CLI#exec'
      01 	from /usr/local/rbenv/versions/3.4.6/lib/ruby/3.4.0/bundler/vendor/thor/lib/thor/command.rb:28:in 'Bundler::Thor::Command#run'
      01 	from /usr/local/rbenv/versions/3.4.6/lib/ruby/3.4.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in 'Bundler::Thor::Invocation#invoke_command'
      01 	from /usr/local/rbenv/versions/3.4.6/lib/ruby/3.4.0/bundler/vendor/thor/lib/thor.rb:538:in 'Bundler::Thor.dispatch'
      01 	from /usr/local/rbenv/versions/3.4.6/lib/ruby/3.4.0/bundler/cli.rb:35:in 'Bundler::CLI.dispatch'
      01 	from /usr/local/rbenv/versions/3.4.6/lib/ruby/3.4.0/bundler/vendor/thor/lib/thor/base.rb:584:in 'Bundler::Thor::Base::ClassMethods#start'
      01 	from /usr/local/rbenv/versions/3.4.6/lib/ruby/3.4.0/bundler/cli.rb:29:in 'Bundler::CLI.start'
      01 	from /usr/local/rbenv/versions/3.4.6/lib/ruby/gems/3.4.0/gems/bundler-2.6.9/exe/bundle:28:in 'block in <top (required)>'
      01 	from /usr/local/rbenv/versions/3.4.6/lib/ruby/3.4.0/bundler/friendly_errors.rb:117:in 'Bundler.with_friendly_errors'
      01 	from /usr/local/rbenv/versions/3.4.6/lib/ruby/gems/3.4.0/gems/bundler-2.6.9/exe/bundle:20:in '<top (required)>'
      01 	from /usr/local/rbenv/versions/3.4.6/bin/bundle:25:in 'Kernel#load'
      01 	from /usr/local/rbenv/versions/3.4.6/bin/bundle:25:in '<main>'
...

Details

This Pull Request updates the write_crontab method to handle crontab output and prevent SIGPIPE.

Below is the result of running update-crontab with this patch applied on CentOS Stream 10.
The Capistrano deployment completes successfully without errors:

$ bundle exec cap production whenever:update_crontab
00:00 whenever:update_crontab
      01 /usr/local/rbenv/bin/rbenv exec bundle exec whenever --update-crontab my-app_production --set environment=production --roles=web,app,db 
      01 Backup of deploy's previous crontab saved to /home/deploy/.cache/crontab/crontab.bak
      01 [write] crontab file updated
    ✔ 01 [email protected] 0.160s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SIGPIPE error when running update-crontab on CentOS Stream 10
1 participant