"path to me" returning UUID instead of useful path

I’ve recently moved to Big Sur, and am working through my long list of Applescripts, recompiling and making the (usually few) changes necessary for this new environment.

There’s a handful which comprise an application and one or more compiled script files (.scpt) and I’m having trouble getting them to run correctly on Finder double-click. I use [format]path to me[/format] at the start, to figure out the path to the script files so I can load them, but when double-clicked in the Finder I get a string like this:[format]94E5DF40-13F9-48AC-9DDE197EA399:d:myapp.app[/format]

What’s even weirder is that the string actually changes every now and then! Naturally, what I expect is [format]MyDisk:Users:SkiAddict1:Documents:Code:Applescripts:myapp.app[/format] and that’s what I get if I run from within the Script Editor.

It’s clearly got something to do with compiled scripts in an app bundle, since a simple app like the following:

set str to (path to me)
display dialog (str as text)

performs as expected.

Does anyone know what’s going on here? I’d be grateful for some ideas as to how to solve this!

What you’re seeing is known as app translocation, or Gatekeeper path randomization, a security feature introduced in macOS 10.12. The simplest method to solve the problem is to move your script app the Applications folder, and run it there. My memory is a bit rusty, but I think it only needs to be run there once.

OH! I tripped over translocation the other day in another context, but didn’t think about it here. You are quite right, that’s all it was.

For future reference, I simply needed to move the app into Applications, run it once there, and then I was able to command-drag it back where I want it. Even across a restart the problem has not recurred, so I think we can conclude it’s solved.

Thank you so much, Shane :slight_smile: