Lion - The action "Run AppleScript" encountered an error.
Opened this issue · 10 comments
I am getting this error, after attempting to run either of the two services. I have quadruple verified my install paths are correct.
I've updated all three paths to:
/opt/local/bin/uncrustify
Which is where MacPorts installed Uncrustify.
Here is the Console output, the results of which I'm unable to find any Google hits on:
4/20/12 3:17:45.000 PM com.apple.automator.xpc.workflowServiceRunner: Could not connect the action buttonPressed: to target of class NSApplication
4/20/12 3:17:45.000 PM com.apple.automator.xpc.workflowServiceRunner: 2012-04-20 15:17:44.998 WorkflowServiceRunner[6285:1707] Could not connect the action buttonPressed: to target of class NSApplication
4/20/12 3:17:45.000 PM com.apple.automator.xpc.workflowServiceRunner: Could not connect the action buttonPressed: to target of class NSApplication
4/20/12 3:17:45.001 PM com.apple.automator.xpc.workflowServiceRunner: 2012-04-20 15:17:44.999 WorkflowServiceRunner[6285:1707] Could not connect the action buttonPressed: to target of class NSApplication
4/20/12 3:17:45.001 PM com.apple.automator.xpc.workflowServiceRunner: Could not connect the action buttonPressed: to target of class NSApplication
4/20/12 3:17:45.001 PM com.apple.automator.xpc.workflowServiceRunner: 2012-04-20 15:17:45.000 WorkflowServiceRunner[6285:1707] Could not connect the action buttonPressed: to target of class NSApplication
4/20/12 3:17:45.002 PM com.apple.automator.xpc.workflowServiceRunner: Could not connect the action buttonPressed: to target of class NSApplication
4/20/12 3:17:45.005 PM com.apple.automator.xpc.workflowServiceRunner: 2012-04-20 15:17:45.002 WorkflowServiceRunner[6285:1707] Could not connect the action buttonPressed: to target of class NSApplication
4/20/12 3:17:45.515 PM com.apple.automator.xpc.workflowServiceRunner: WorkflowServiceRunner received error running Workflow Service at /Users/Josh/Library/Services/Uncrustify Document.workflow: The action “Run AppleScript” encountered an error.
4/20/12 3:17:45.516 PM com.apple.automator.xpc.workflowServiceRunner: 2012-04-20 15:17:45.515 WorkflowServiceRunner[6285:1707] WorkflowServiceRunner received error running Workflow Service at /Users/Josh/Library/Services/Uncrustify Document.workflow: The action “Run AppleScript” encountered an error.
4/20/12 3:18:09.000 PM kernel: IOSurface: buffer allocation size is zero
4/20/12 3:20:18.000 PM kernel: IOSurface: buffer allocation size is zero
Do you have "Enable access for assistive devices" enabled in your "Universal Access" system preferences?
I do, and if I recall correctly, it's because Divvy requires it.
I disabled it, getting the same issue.
Hi @LifeCoder45 — sorry for not being clearer, you definitely need to leave assistive device access enabled for this script to work. The only other thing I can suggest is that you need to select the text in the document you want to reformat. The "Uncrustify Selected Source Code" workflow is always more reliable in my daily grind than the full document variant — you could try that and see if it works?
The other thing to check is that uncrustify
is working when you run it manually.
I just ran in to this same thing and found it was due to errors in my uncrustify.cfg (which was mostly the gist from http://gist.github.com/261662/)
When I ran uncrustify manually, I would see:
/Users/bcooke/.uncrustify.cfg:776 Unknown symbol 'align_pp_define_together'
/Users/bcooke/.uncrustify.cfg:845 Unknown symbol 'nl_typedef_blk_start'
/Users/bcooke/.uncrustify.cfg:849 Unknown symbol 'nl_typedef_blk_end'
/Users/bcooke/.uncrustify.cfg:853 Unknown symbol 'nl_typedef_blk_in'
/Users/bcooke/.uncrustify.cfg:857 Unknown symbol 'nl_var_def_blk_start'
/Users/bcooke/.uncrustify.cfg:861 Unknown symbol 'nl_var_def_blk_end'
/Users/bcooke/.uncrustify.cfg:865 Unknown symbol 'nl_var_def_blk_in'
/Users/bcooke/.uncrustify.cfg:1161 Unknown symbol 'ls_code_width'
/Users/bcooke/.uncrustify.cfg:1244 Unknown symbol 'nl_remove_extra_newlines'
These seemed to cause uncrustify to return a non-0 exit status, so the script would bail.
I simply commented out each offending line and now uncrustify returns a happy 0 status and the workflows are working correctly for me. Hope that helps.
Errors aren't reported particularly well by my services, sadly (I'm not sure it's possible to intercept errors in Automator Workflows — I've never looked into it). Thanks for the information, @bricooke — hopefully it helps @LifeCoder45.
I followed the instructions on http://www.nanaimostudio.com/blog/2012/6/27/the-productive-apple-developer-part-ii.html and ran into the same issue.
However, in my case, it doesn't appear to be a bad .cfg because when I execute the same command, prepended by a "pbpaste | ", and if I place the text into the clipboard, it gets output just fine, without an error msg in Terminal.
I am using 10.7.4 and access for assistive devices is enabled.
Restarting OSX hasn't helped, either.
I'll keep looking. Wouldn't be surprised if this is a new Lion bug - seen to many reggressions recently with Lion :(
@tempelmann I use these scripts daily without issue under 10.7.4 and 10.8.0 DP4. Have you tried using my scripts in place of the one that Nanaimo Studio has posted?
The script invocation itself works fine when I test it from the cmdline.
After googling around I am convinced it is due to a damaged Lion install (I have been upgrading this system forever, never a clean install), as others reported that a reinstall of Lion did fix it for them.
Update:
When I execute the script in automator, by prepending it with a "Get Specified Text" action, it fails with a very unhelpful error msg.
But then I found a fix, after all: If I add a line "exit 0" to the end of the script, it works.
So, somehow, uncrustify returns a non-zero result, which upsets Automator. Why the command returns non-zero (which indicates a failure) is unclear to me, though, because the cmd did work and outputs a reformatted source code, just like it should.