Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

my .plist looks like below ... In /var/log.system.log I can see

(com.example.exampled[24728]): posix_spawn("/usr/local/bin/ruby /Users/radek/Sites/sinatrasvn/web.rb", ...): No such file or directory
(com.example.exampled[24728]): Exited with exit code: 1
(com.example.exampled): Throttling respawn: Will start in 10 seconds

but if I run /usr/local/bin/ruby /Users/radek/Sites/sinatrasvn/web.rb the script works fine. Any idea?

       <?xml version="1.0" encoding="UTF-8"?>
       <!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN       http://www.apple.com/DTDs/PropertyList-1.0.dtd >
       <plist version="1.0">
                 <string>/usr/local/bin/ruby /Users/radek/Sites/sinatrasvn/web.rb</string>
share|improve this question

1 Answer 1

up vote 10 down vote accepted

launchd doesn't use the shell to run programs; it uses the exec system call. This is why the plist you have above uses an array.

You are setting a single element of that array to a string containing a space, which leads launchd to attempt to exec("/usr/local/bin/ruby /Users/radek/Sites/sinatrasvn/web.rb") — which, sure enough, is not the name of a file. Instead, you want to set the array:


This will pass the paths as individual arguments to exec(), and the right thing will happen.

share|improve this answer
wow.Nicely put.Thank you. Do I have to call launchctl load /Users/radek/Library/LaunchAgents/sinatra.plist after reboot or it is good enouth to call it once? –  Radek Mar 4 '11 at 1:42
Everything in ~/Library/LaunchAgents will be automatically loaded every time you log in, so launchctl load ... is only needed for the current login session (or you could just log out & back in). BTW, for locally-developed launchd items like this, you should probably use "local." instead of "com.example." as a label prefix. –  Gordon Davisson Mar 4 '11 at 3:36
Absolutely stellar answer man. Kudos. –  peelman Mar 4 '11 at 14:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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