Padoriku Posted December 20, 2024 Posted December 20, 2024 (edited) Hi folks, I'm pretty new to Alfred. I want to make my first workflow but I encountered some issues. I have replicated this issue under a minimal setup. This workflow only activates on input keyword "pclip", and triggers an AppScript that activates the "Preview" app. The script is an "External Script". I tested the AppleScript in terminal and it successfully opens "Preview". The script is located at `Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.F456C3BE-34D3-4CC4-8BD3-A2FC01F44022`. The script looks like this: The problem: when running this workflow through the keyword 'pclip', nothing happens. The debugger shows something, but my script log isn't in debugger output. Also, I found that the first time I launch it in a while Alfred shows a popup saying "Task '/Users/patrickmao/repos/alfred/pclip.applescript' failed with reason 'Couldn't posix_spawn: error 8'". I made sure I do `sudo chmod +x pclip.applescript, but that doesn't seem to help. Interestingly, the script does work correctly if I select "/usr/bin/osascript (AppleScript)" as Language instead of "External Script". So I suspect the issue is maybe related to permissions. What other permissions or setup does Alfred need other than +x for all users/groups? - Github link of this workflow. Thanks in advance for your insights! Edited December 20, 2024 by Padoriku
vitor Posted December 20, 2024 Posted December 20, 2024 sudo is for elevating permissions, you shouldn’t use it for this case. The problem is that you’re missing a shebang at the top of the script, specifically #!/usr/bin/osascript. Otherwise macOS doesn’t know how to execute the file. It also wouldn’t work in a Terminal if you just gave it the path to your script, which means you’re likely to be doing /usr/bin/osascript /path/to/script which is the same as selecting the language in Alfred. Either you need a shebang or to define the interpreter to run the file, that is true both inside and outside Alfred. When sharing a workflow in the future, please share the exported file as opposed to the files inside. The goal is that we should be able to download it and install it easily to be able to see your workflow and help you better. Padoriku and FireFingers21 2
FireFingers21 Posted December 20, 2024 Posted December 20, 2024 @Padoriku When running your code as an External Script, you need to specify your desired runtime with the proper shebang. In your case, that would be this: #!/usr/bin/osascript Padoriku 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now