I want to periodically run a ruby gem based command. I am using RVM and following the tutorial set out here.

My ruby task is called daily_checks.rb and is as follows:

#!/usr/bin/env ruby
puts 'in here'
Dir.chdir('/Users/Chris/Documents/Sites/mentor') do
  audit = `bundle-audit`
  system(%(osascript -e 'display notification "#{audit}" with title "bundle-audit"'))

I have set up an RVM alias and a bash file at /usr/local/bin/regular_checks.sh

/Users/Chris/.rvm/wrappers/regular_checks/ruby /Users/Chris/Documents/Sites/mentor/script/daily_checks.rb

When I run /usr/local/bin/regular_checks.sh then the ruby file is executed and works successfully.

I have then setup a plist at /Users/Chris/Library/LaunchAgents/local.temp.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">

When I run this job using launchControl, the job appears to fail with error number 78. The puts 'in here' in the ruby file is not executed.

The file permissions appear the same as in the tutorial i.e.

-rwxr--r--  1 Chris  staff   699 24 Nov 20:16 local.temp.plist
-rwxr-xr-x  1 Chris  admin  111 24 Nov 20:10 /usr/local/bin/regular_checks.sh
-rwxr-xr-x  1 Chris  admin   207 25 Nov 13:38 daily_checks.rb

What is error 78, and why is the file not running properly?


It appears that the error 78 is because the /usr/local/bin/regular_checks.sh file does not have #!/bin/bash as the first line. The full content of the file should be

/Users/Chris/.rvm/wrappers/regular_checks/ruby /Users/Chris/Documents/Sites/mentor/script/daily_checks.rb
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.