-
Notifications
You must be signed in to change notification settings - Fork 725
Open
Description
When running whenever:update_crontab
on CentOS Stream 10, the following error occurs and capistrano deployment fails to complete:
$ 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>'
...
Cause
The error occurs in the following part of the code:
https://github.com/javan/whenever/blob/v1.0.0/lib/whenever/command_line.rb#L77-L82
It seems that a SIGPIPE (signal 13) is raised when running crontab -
via IO.popen.
# lib/whenever/command_line.rb
...
IO.popen(command.join(' '), 'r+') do |crontab|
crontab.write(contents)
crontab.close_write
end
success = $?.exitstatus.zero?
# puts $?.exitstatus # => nil
# puts $? # => #<Process::Status: pid 15842 SIGPIPE (signal 13)>
Root cause
Starting with CentOS Stream 10, updating the crontab automatically saves a backup and writes a message to standard output, which appears to trigger the SIGPIPE.
CentOS Stream 10
$ echo "# test" | crontab -
Backup of deploy's previous crontab saved to /home/deploy/.cache/crontab/crontab.bak
$ echo $?
0
$ crontab -l
# test
CentOS Stream 9
$ echo "# test" | crontab -
$ echo $?
0
$ crontab -l
# test
System configuration
- OS: CentOS Stream 10
- vagrant: bento/centos-stream-10 (virtualbox, 202508.03.0, (arm64))
- rails: 8.0.2.1
- ruby: 3.4.6
- whenever: 1.0.0
Metadata
Metadata
Assignees
Labels
No labels