Choose folder default location does not work - SOLVED


being on Mojave I recently tried to run this:

set rootDir to choose folder with prompt ¬
“Select the Root Folder:” default location (alias “SanDisk500GB_APFS:”)

It works, but the dialog always points somewhere unrelated, i. e. SD’s application package.

This happens only if the location is not on the start volume.

I suspected that this might be related full disk access but it turns out that I am unable to grant the script the required access when saved as applet or enhanced applet.
I wonder why. I have quite a couple of applets having been granted full access.

I can, of course, navigate to any desired folder from that dialog and choose it. Only the default location is not the desired one.

Any pointers on how to solve this are very much appreciated.


What happens when you try?

Nothing. I drag the applet’s icon over onto the list of apps to be granted full disk acess, the GUI responds visually, but the applet does not end up staying in the list. Just as if nothing happened.
I can drag any other application and it sticks.

Besides, despite that, it seems that I can navigate anywhere I like, simply the default location is not properly displayed initially in the dialog.


BTW: I received 9 identical mails about your reply…

That will happen if your applet modifies itself when running, usually by changing the value of a top-level variable. You can avoid this by going to Preferences -> Building and checking Lock main script.

Thanks. I guess this preference setting is available only in SD 8. I am using SD 7. (Without ever coming across any similar problem…)
Tried to lock the main script in the app’s package from the Finder, but that didn’t help.
And, BTW, removing any variables from the script, leaving just the bare bones call to choose folder changes nothing.
Do I have to upgrade to SD 8 to make this work?

Additionally: every other applet I tried (wether it really needs full disk access or not, mostly not) is easily granted access. I really don’t get what is happening here.


Try locking just the file in the applet called main.scpt.

Yes, this is what I did. Before trying to lock the applet itself. Tried to lock both now, no change.

And, again, on a side note: Should it work properly when run inside SD?
SD of course has been granted all the privileges, full disk and automation (the latter shouldn’t concern us in this case).

I’m not sure what you mean.

Just tried SD 8 - no change. Something, but what?, is rotten here.

Provided this really has something to do with full disc access or other permissions: SD has them all, so running the script in SD should not cause a problem, but executing the applet potentially might.

And one more observation: The default location for saving scripts from SD is within SD’s application package. Incidentally, this is the same location I get when running choose folder from SD. This is odd. Is this normal? (On a side note: I deactivated Jon Gotow’s Default Folder for SD, no change.)

Have you checked that the Bundle ID is unique?

No - this should be a very valuable hint. Thank you.
Just saved it as “Untitled”, since I was just experimenting.
But a copy saved with unique ID has the same bug. Sad.

Did some more experiments:
Booted into safe mode (holding shift at boot). In safe mode I was able to grant an app with a unique bundle ID full disk access.
Same result under normal login.
Still, default location does not show the default location. The location is always the first level of the respective app’s own package.

Send me a copy in a message.

OK, I mis-interpreted what you were saying. What you’re seeing is a bug. It probably relates to the deprecation of alias manager code, so it’s unlikely to be fixed. Unless you can use something other than an alias, you can’t start from a location not on the startup disk.

OK, thanks for clearing this up.
One follow up question: How could I use “something other than an alias” in this case?

Thanks a lot - this was driving me almost mad …



set rootDir to choose folder with prompt ¬
	"Select the Root Folder:" default location ¬
 (file "SanDisk500GB_APFS:") as alias

instead of

set rootDir to choose folder with prompt ¬
"Select the Root Folder:" default location (alias "SanDisk500GB_APFS:")

That’s all.

Shane, thank’s again for all your invaluable hints. I’d have never figured this out on my own!