Document could not be autosaved

I’m experiencing a problem every time I try to compile a script that’s located in iCloud Drive (10.11.6).

Although the script will manually save (i.e, when I do Cmd-S), when I re-compile the script after any change I immediately get this pop-up:

Curious thing is that this doesn’t occur with the same script saved anywhere else on that machine other than iCloud Drive.

It also doesn’t occur on my iMac. However, I notice a difference, on my iMac, Script Debugger doesn’t appear to attempt to save on compile. This is actually the behaviour I prefer.

So two questions:

  1. Is there a setting I’ve missed for this somewhere to stop SD trying to autosave on compile?
  2. Any thoughts on why this appears to cause a problem with scripts saved in iCloud Drive?

EDIT: Oh, btw, if it matters: the Autosave folder in Application Support is empty.



That’s rather odd, because that’s not a Script Debugger error; it’s presumably coming from iCloud. FWIW, I can’t reproduce the problem here (10.12) – compiling with auto-saving causes no problems.

Have you looked in ~/Library/Mobile Documents/com~apple~CloudDocs/ ?

You can turn off autosaving when compiling like this:

use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"

current application's NSUserDefaults's standardUserDefaults()'s setObject:false forKey:"PrefAutoSaveOnCompile"

However, I’d be interested to hear what happens if you turn it on for your iMac.

Well, the SD icon is in the dialog, so I’d assume it’s coming from SD, but in any case, neither of the machines have the PrefAutoSaveOnCompile key set:

The domain/default pair of (/Users/sphil/Library/Preferences/com.latenightsw.ScriptDebugger6, PrefAutoSaveOnCompile) does not exist

I did a diff on the two plists in TextWrangler, but didn’t see anything that looked like it related to compile or saving. I might just default delete the SD prefs on the MBP (the one that produced the error) and see if that helps.

Have you looked in ~/Library/Mobile Documents/com~apple~CloudDocs/ ?

Sorry, didn’t quite understand. That’s the path to iCloud Drive - what is it I should look for? The script exists at the path if that’s what you mean, and - like I said - saves and runs normally. The only issue is with compiling (it does compile, of course, it’s just the compile comes with the autosave error). By the way, when I say ‘the script’, I should point out it’s not restricted to a single script; it’s any script I save in iCloud Drive on the MBP.

Anyway, I’ll play around with it a bit (when I can get my son off the MBP). Likely this is a local fault. I had some other issues with iCloud Drive and Xcode (big mistake trying to run Xcode projects from iCloud - back to bitbucket for me). I suspect iCloud Drive is not really going to work out as my hoped-for alternative to Dropbox, but I digress.

Sorry, I wasn’t clear – SD is presenting it, but the content is from an OS NSError.

That’s where the autosave should happen too. But if PrefAutoSaveOnCompile is off, something else is happening.

It sounds lame, but a restart might be in order.

Well, I deleted the prefs on the MBP, now the problem is intermittent, but still occurring about 1 in 3 or 4 times.

I’m inclined to think this is an issue with iCloud Drive, but maybe a reboot will clear things up. If not, I’ll BR it with Apple.

So it occurred to me to see what happens with Script Editor. SE will save, run, compile the file without issue. However, after closing it, SE won’t open it again. I can open it with SD after that, compile, run it, save it, but SE still refuses to have anything to do with it. Finder can see that the script is there and compiled, but even if I control-click in Finder and do ‘Open with…’ and choose Script Editor, I just get the null error.

EDIT: subsequently moving that file out of iCloud and to the Desktop: now SE can open it again.

I think my iCloud days are numbered. I can’t live with this kind of unreliability.

After a reboot, SD6 no longer autosaves on compile, which appears to have cured that problem (although again, the defaults still say the PrefAutoSaveOnCompile key doesn’t exist, so I don’t know what happened to stop it).

I guess it’ll remain a curiosity. Till the next time…

The absence of the PrefAutoSaveOnCompile key in the SD6 user defaults means that SD’s built-in default (YES) for this value is used.