Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lion - The action "Run AppleScript" encountered an error. #5

Open
LifeCoder45 opened this issue Apr 20, 2012 · 10 comments
Open

Lion - The action "Run AppleScript" encountered an error. #5

LifeCoder45 opened this issue Apr 20, 2012 · 10 comments

Comments

@LifeCoder45
Copy link

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
@tonyarnold
Copy link
Owner

Do you have "Enable access for assistive devices" enabled in your "Universal Access" system preferences?

@LifeCoder45
Copy link
Author

I do, and if I recall correctly, it's because Divvy requires it.

@LifeCoder45
Copy link
Author

I disabled it, getting the same issue.

@tonyarnold
Copy link
Owner

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.

@bricooke
Copy link

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.

@tonyarnold
Copy link
Owner

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.

@tempelmann
Copy link

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 :(

@tonyarnold
Copy link
Owner

@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?

@tempelmann
Copy link

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.

@tempelmann
Copy link

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.

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

No branches or pull requests

4 participants