Run Shell Script encountered an error
Closed this issue · 11 comments
- Installed uncrustify via homebrew
- Copied config file to ~/uncrustify.cfg
- Copied workflow files to ~/Library/Services
- Opened a project and selected some text
- Selected Xcode/Services/Uncrustify Selected Text
Error: Run Shell Script Encountered An Error
@memmons — could you try pulling the latest code and replace the "Uncrustify Selected Text" service with the new "Uncrustify Selected Source Code" service? It works OK for me here — I was seeing the same issue with the old "Text" service as well.
Same problem here.
@tonyarnold - I am already using "Uncrustify Selected Source Code.workflow"
OK, the problem usually turns out to be that the workflow script cannot find the uncrustify binary. Can you both do me a favour? Run the following commands in Terminal.app
and post the output back here (like so):
Input:
Result:
Input:
Result:
which uncrustify
`````` /usr/local/bin/uncrustify```
echo $PATH
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/bin
By the way, after copy/remove the files in ~/Library/Services for a few times, now I can only see "No Services Apply" in the Services menu, wondering how to bring back the installed services in the XCode's menu.
Thanks @tszming — you may want to check under "System Preferences → Keyboard → Keyboard Shortcuts" and make sure that the services are enabled under the "Services" entry. You may need to quit and re-open Xcode once you've done this — I'm not sure.
Yes, both services have been selected in the Keyboard Shortcuts but they just disappeared from XCode4. But I am sure they are not your problem, thanks anyway.
Hi, if I run uncrustify from the console or in automator without the -q I get the following errors and Xcode also shows an error.
Unknown symbol 'nl_before_return' Unknown symbol 'nl_before_else' Unknown symbol 'nl_after_else' Unknown symbol 'nl_before_else_if' Unknown symbol 'nl_after_else_if'
If I remove these lines from the config file the service works fine for me in Xcode.
I am using uncrustify from homebrew (uncrustify 0.57).
Hi guys
I had some trouble with spaces in my files names, so I'd recommend double quoting the file path in your script to:
set formatted_source to do shell script "/opt/local/bin/uncrustify -f "" & current_document_path & """
Thanks
Peter
I came across this problem too. Although uncrustify is in my bash path, I found that automator only loads the default paths when running a script.
You can see which paths automator is using by adding an automator step to print out this setting. e.g.
printenv PATH
To fix this, I opened the workflows and expanded '/usr/bin/env uncrustify' to my uncrustify location:
/usr/local/bin/uncrustify -l OC -c ~/.uncrustify.cfg
You could also try a symlink to uncrustify from /usr/bin/, which is in automators default path.
Don't ask me why, but appending a pipe and cat solved this problem for me. Without the cat I had the same "Run Shell Script encountered an error" message.
So this one works:
/usr/local/bin/uncrustify -l OC -c ~/.uncrustify.cfg | cat
Thanks guys — I've updated the instructions to include a note about updating the path of the uncrustify binary in the workflow. It should work properly now if you've properly followed the instructions.