Applescript with emoji icon fail to run
Hi,
first of all I want to say that I love what you are doing with Raycast. I'm tweaking it a bit with script and I have bumbed to tricky issue. When I try to run applescript in Raycast to which contains emoji icon it won't run if there is a tell block over multiple lines.
I have tried sleep command from this repo and it worked fine. But when I tried to run toggle-desktop-icons it failed and nothing happen. I have tried to change mode to compact and it write Operaction couldn't be completed. Exec format error.. But if I delete # @raycast.icon line script works.
macOS version 10.15.7
Tested it with Raycast 1.1.0 and 1.1.1.
Hi @Pustelto. Thanks for reporting. That's indeed a tricky issue. I haven't managed to reproduce this problem locally (macos 10.15.7). Did you see this error when running any other apple scripts with emoji icon?
Also could you try switching mode to fullOutput and tell me what do you see there?
Hi, I had this issue on 10.15.x version (not sure about exact version though, and it's still there in macOS 11.0.1). I tested it with my custom apple script to connect to VPN. The issues was the same. Adding fullOutput doesn't give much help since there is not error at all (see the attached pic). However if I run the script in Apple's ScriptEditor it works. So problem is probably not with the script itself.
I am running zsh shell v5.8 (x86_64-apple-darwin20.0), if that have any value in this case. Also including screens of my scripts setup.

@PitNikola I try to remove # @racast.icon but always send me an error :(
Here's my script, may help you to reproduce the issue:
#!/usr/bin/osascript
# @raycast.title Open with Chrome
# @raycast.author Siyuan Zhang
# @raycast.authorURL https://github.com/kastnerorz
# @raycast.description Open Current Safari Tab with Chrome
# @raycast.icon 🧭
# @raycast.mode silent
# @raycast.packageName system
# @raycast.schemaVersion 1
tell application "Safari"
set currentUrl to URL of current tab of front window
end tell
tell application "Google Chrome"
open location currentUrl
end tell
@kastnerorz your script works on my machine. What error do you get when removing the @raycast.icon from the script? Also, could you make sure to set the encoding to UTF-8. I attached a screenshot on how to do it in VS Code. We encountered some issues in the community that the encoding was sometimes set to something else for AppleScript and it broke the execution.

@thomaspaulmann I tried to re-save toggle-desktop-icons.applescript taken from your repo to UTF-8 (was UTF-16 LE), but after that if I refresh the scripts in raycast settings I don't see the script anymore at all.
That is even weirder. Did you make sure that the script is executable? You can run chmod +x <path to file> to make it executable. When you just download the file, the flag is sometimes not set.
@thomaspaulmann I think it's the encoding issue. I saved it with script editor, after I copy and re-edit with vim, it works.
Great! I'm gonna close this issue then. Might be worth to add something to the AppleScript template or setup.
@thomaspaulmann I tried to change encoding to UTF-8, but still no success. I still have problems to add icons to some other apple scripts (icon is not displayed). I will try to rewrite non-working apple script from scratch in UTF-8 to double check, but so far this seems like not-working for me. I have checked the permission and I have execute permission for all my scripts.
In case it is still helpful to anyone:
I just tried creating an applescript script and I got hit with [Exec format error] when trying to run it. After reading this thread, removing the default Raycast line # @raycast.icon 🤖 solved the problem.
This issue does not seem to be resolved, it seems to happen with every AppleScript created through Raycast.
Is it possible that when Raycast generates a new AppleScript file, it saves it with the wrong character encoding? At the least, the issue seems to be caused by the Emoji that Raycast is adding to the generated file, and it would be resolved by removing that.
could you make sure to set the encoding to UTF-8. I attached a screenshot on how to do it in VS Code. We encountered some issues in the community that the encoding was sometimes set to something else for
AppleScriptand it broke the execution.
I was having this issue, and the above suggestion fixed it for me. In VSC I've re-saved the file with UTF-8 encoding and my script started working, without making any other change.
Also, could you make sure to set the encoding to UTF-8. I attached a screenshot on how to do it in VS Code.
FYI: I was having the same issue. Above suggestion from @thomaspaulmann fixed it. For some reason every time I edit the script in Script Editor it encodes it as UTF-16, and then Raycast won't run the script. Changing the script file to UTF-8 fixes that.
Yeah Script Editor is a bit annoying. I would suggest to edit it in another editor like VS Code.
I am not quite sure, whether it is related to this issue, but I have a script that works as expected with Script Editor. As soon as I want to run it with Raycast, the script is not working. I am getting an error that the "tell" command is not found. It is already saved as UTF-8.
Would be useful to get an error message stating that the file was saved in the wrong encoding. Just spent half an hour troubleshooting due to the Script Editor saving it in UTF16 by default. After setting the encoding to UTF8 it worked again, but the error message I got wasn't helpful:
Reason: Process tried to run, but failed Domain: scripts Time: 12:25:51.852 Underlying: Domain: NSPOSIXErrorDomain 8 Reason: Exec format error
I hope by putting this here, people will find the resolution easier. Bonus points if Raycast could hint to the user that the encoding isn't correct.
Adding to the comment above Note that VSCode will give you the encoding in its status bar.
Also @thomasbaart thanks for the Kyria!
You can force-change the encoding in VS Code using the command palette:
Same issue in 2024. Switching the encoding to UTF-8 in Sublime seems to fix it. Raycast should implement a fix.
Same issue in 2024. Switching the encoding to UTF-8 in Sublime seems to fix it. Raycast should implement a fix.
here is already a clear solution, and I don’t think it’s too troublesome to implement. As for why the Raycast maintainers haven’t done this, I don’t understand. I support you.