Jump to content

Permission Error on External AppleScript Script

Recommended Posts

Version: Alfred 3.4.1


I am new to Alfred and am running into a problem. I created an AppleScript to send information from Outlook 2016 to OmniFocus 2. I have it set to run an external script (makes it much easier for me to make changes and test). I created a hotkey to run the script. When I launch the script with the hotkey, I get this error:

Unable to run task!

Reason: launch path not accessible

The external script may not exist, or does not have execute (+x) permissions.

I have tried putting in the script folder for OmniFocus, Outlook and Alfred, but get the error each time. I am sure I a doing something simple wrong. Thanks in advance for your help!

Link to comment



If you set the preference in Alfred to "Run AppleScripts instead of opening" (found in: "Alfred Preferences -> File Search -> Advanced -> AppleScripts [ ]  Run AppleScripts instead of opening), then when you search and open an AppleScript file in Alfred then Alfred will run it directly. So, no need to create a script for that. Just use a Hotkey trigger connected to an Open File action (where you can directly drag and drop the AppleScript that you want to run).


However, if you want to go with creating a script, then you would be better using a Bash script file that run the AppleScript file using the osascript command.




osascript path/to/your/applescript/file.scpt

Also, before you'll be able to use it, you will need to make your Bash file executable using `chmod +x yourFile.sh`


Or instead of creating a Bash file, just use a "Run Script" action in Alfred set to Language "/bin/bash" and with the osascript command inside "osascript path/to/you/applescript/file.scpt" 

Edited by GuiB
Link to comment
1 hour ago, elguapo said:

does not have execute (+x) permissions


@GuiB gave some solutions, but didn't explain what the root cause of the problem is.


(Excuse me if this explanation comes across as for-idiots or patronising: I'm aiming to explain this just once and link to it in future, so I'm writing this for total noobs.)


macOS is basically a UNIX system with Cool Apple Shit layered on top.


Alfred itself exists in the Cool Apple Shit layer, but workflows are at the lower UNIX level. This means they must, essentially, be UNIX programs.


As such, an External Script element can only run a UNIX executable, which is to say something you can run from a shell.


Concretely, that means the execute bit must be set (run chmod +x /path/to/script in a shell), but also that it must be a UNIX program or a script with a shebang.


AppleScript, as the name implies, belongs to the higher Cool Apple Shit layer (though AppleScript is pretty damn far from cool), and as a result you can't run it directly via the UNIX subsystem.


Fortunately, Apple has written a bunch of programs to access the Cool Apple Shit from the underlying UNIX layer. As @GuiB explained, the one you need to run AppleScript scripts from the UNIX layer is osascript. But there are other super-cool ones, like security, which provides access to the macOS Keychain, and mdfind, which lets you run Spotlight queries from the command line/scripts/workflows.



Link to comment

@deanishe Making this comment since you mentioned you wanted to make the post clear for newbies and link to it in the future.


1 hour ago, deanishe said:

which is to say something you can run from a shell


I’d expand a bit more on that. For example: “which is to say something you can run from a shell (the command-line interface that the Terminal app uses to run commands)”.


1 hour ago, deanishe said:

program or a script with a shebang.


I’d link to an explanation of what a shebang is.

Edited by vitor
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...