NilObjectException from SpecialFolder.Temporary on El Capitan?

UUID doesn’t contain any special characters such as : or / ?

[quote=222808:@Michel Bujardet]There seems to have be some random issues with opening files during beta.
https://github.com/atom/atom/issues/7811

Could your user have an older release ?[/quote]

Unfortunately not. They seems to be using the release version. Hoping OSX10.11.1 will fix this.

Yeah, we’re seeing it with the release version, too.
I’ve put together this little chunk of code, but I’m not sure if it’s going to make any difference. I can’t test for SpecialFolder.Whatever being nil and then use it in the next line, because it seems like it’s highly intermittent (we have a lot of calls to SpecialFolder.Stuff) so I’m having to check it’s not nil and then return that as a folderitem to be used. Might work. Might not. Bleh.

[code] Function getSpecialFolder(type as String) As FolderItem
dim f as FolderItem = Nil
dim changeCount as integer = 0
dim maxChangeCount as integer = 30 // how long to wait before returning nil, which will probably cause a bomb out

	  if type="Applications" then
	    f = SpecialFolder.Applications
	    while f = Nil and changeCount < maxChangeCount
	      call writeLogFile( "SpecialFolder.Applications was nil: " + CStr( changeCount ) )
	      DelayMBS 0.1
	      changeCount = changeCount + 1
	      f = SpecialFolder.Applications
	    wend
	    if f= Nil then app.exceptionTracker = "SpecialFolder.Applications was nil" + chr(10) + app.exceptionTracker
	  elseif type="ApplicationData" then
	    f = SpecialFolder.ApplicationData
	    while f = Nil and changeCount < maxChangeCount
	      call writeLogFile( "SpecialFolder.ApplicationData was nil: " + CStr( changeCount ) )
	      DelayMBS 0.1
	      changeCount = changeCount + 1
	      f = SpecialFolder.ApplicationData
	    wend
	    if f= Nil then app.exceptionTracker = "SpecialFolder.ApplicationData was nil" + chr(10) + app.exceptionTracker
	  elseif type="Preferences" then
	    f = SpecialFolder.Preferences
	    while f = Nil and changeCount < maxChangeCount
	      call writeLogFile( "SpecialFolder.Preferences was nil: " + CStr( changeCount ) )
	      DelayMBS 0.1
	      changeCount = changeCount + 1
	      f = SpecialFolder.Preferences
	    wend
	    if f= Nil then app.exceptionTracker = "SpecialFolder.Preferences was nil" + chr(10) + app.exceptionTracker
	  elseif type="Desktop" then
	    f = SpecialFolder.Desktop
	    while f = Nil and changeCount < maxChangeCount
	      call writeLogFile( "SpecialFolder.Desktop was nil: " + CStr( changeCount ) )
	      DelayMBS 0.1
	      changeCount = changeCount + 1
	      f = SpecialFolder.Desktop
	    wend
	    if f= Nil then app.exceptionTracker = "SpecialFolder.Desktop was nil" + chr(10) + app.exceptionTracker
	  elseif type="Temporary" then
	    f = SpecialFolder.Temporary
	    while f = Nil and changeCount < maxChangeCount
	      call writeLogFile( "SpecialFolder.Temporary was nil: " + CStr( changeCount ) )
	      DelayMBS 0.1
	      changeCount = changeCount + 1
	      f = SpecialFolder.Temporary
	    wend
	    if f= Nil then app.exceptionTracker = "SpecialFolder.Temporary was nil" + chr(10) + app.exceptionTracker
	  elseif type="UserLibrary" then
	    f = SpecialFolder.UserLibrary
	    while f = Nil and changeCount < maxChangeCount
	      call writeLogFile( "SpecialFolder.UserLibrary was nil: " + CStr( changeCount ) )
	      DelayMBS 0.1
	      changeCount = changeCount + 1
	      f = SpecialFolder.UserLibrary
	    wend
	    if f= Nil then app.exceptionTracker = "SpecialFolder.UserLibrary was nil" + chr(10) + app.exceptionTracker
	  elseif type="UserHome" then
	    f = SpecialFolder.UserHome
	    while f = Nil and changeCount < maxChangeCount
	      call writeLogFile( "SpecialFolder.UserHome was nil: " + CStr( changeCount ) )
	      DelayMBS 0.1
	      changeCount = changeCount + 1
	      f = SpecialFolder.UserHome
	    wend
	    if f= Nil then app.exceptionTracker = "SpecialFolder.UserHome was nil" + chr(10) + app.exceptionTracker
	  end if
	  
	  return f
	End Function

[/code]

Just an update to this. I’ve not added the above code to our app yet. I’ve had a couple more reports from people, but none from 10.11.1 - they’re all 10.11.0. So, it might be a problem fixed in 10.11.1. Or it might be that it hasn’t reared its head on 10.11.1 yet. I’ll keep you posted.

Why do you use “DelayMBS 0.1” in your code, Hamish?

My feeling was that if SpecialFolder wasn’t accessible for any reason it might be a time-based thing. So, waiting a short period of time might be a good thing rather than just trying again straight away. I’m using DelayMBS because we have the MBS plugins and it’s my instinctive go-to mechanism for delaying, but others are available too!

I spoke too soon; the problem still exists in 10.11.1.

This is happening to someone else’s computer, right? It may be a “damaged” permissions issue there, or even a corrupted volume. The disk should first be verified. Then have the user create a listing of the temp folder, maybe by you sending them a custom app that does something like this:

dim f as FolderItem = SpecialFolder.Temporary dim sh as new Shell sh.Execute ("ls -la@ "+f.ShellPath) TextOutputStream.Create(SpecialFolder.Desktop.Child("output.txt")).Write sh.Result

Then see if the folder contains suspicious files or maybe a locked version of your uuid.zip file.

It’s happening on someone else’s computer, yes, and seemingly rather reliably on theirs and a few other (but not many) people’s.

The problem seems to be that specialfolder.temporary doesn’t exist. So, in the code you’ve given, the third line of it, where it talks about f.shellpath, would blow up with a nilobjectexception.

Yes, I know specialfolder.* should always exist, but it seems that sometimes, for whatever reason, it doesn’t. Baffling.

You may be making the wrong assumptions. The Temporary folder isn’t nil, but the child is, possibly. My test code would show what’s up with that.

Any chance they are running on a case-sensitive HFS+ partition? Can you still do that in 10.11 ?

El Capitan won’t install on such a file system.

@Thomas Tempelmann it’s not quite so easy as running that test, because it seems that the problem only occurs occasionally, and it’s on someone else’s computer which I don’t have easy access to. I’ve added yet more logging and some other tests, so I’ll report back when I find more about what’s nil.

Hamish, has someone pointed out already that you may also get a nil from a Child() call if the item exists but is inaccessible? That’s why I suggested to use OTHER ways to check what files that Temp dir has, to rule in/out misbehavior on Xojo’s side.

Hmmm. What would make it inaccessible? Is there any way I can do something to a file on my computer to try to replicate it reliably?

We’ve had some logs through from someone to whom this problem has been occurring. It seems that SpecialFolder.Temporary is returning a folder which doesn’t exist.

We put code in place as follows. Our thought was that SpecialFolder.Temporary didn’t exist temporarily for some reason, and so we should wait a bit and try again. That’s the reason for the little delay.

f = SpecialFolder.Temporary
while (f = Nil or not f.Exists) and changeCount < maxChangeCount
   if f = Nil then
      call WriteLogFile( "SpecialFolder.Temporary was nil: " + CStr( changeCount ) )
   else
      call WriteLogFile( "SpecialFolder.Temporary nonexistent, " + f.NativePath + ": " + CStr( changeCount ) )
   end if      
   DelayMBS 0.1
   changeCount = changeCount + 1
   f = SpecialFolder.Temporary
wend

The log files we get are:

[quote]2015-11-30 16:24:50 SpecialFolder.Temporary nonexistent, : 0
2015-11-30 16:24:50 SpecialFolder.Temporary nonexistent, /Users/home 1/Documents/Light Blue Software/Light Blue/Thumbnails: 1
2015-11-30 16:24:50 SpecialFolder.Temporary nonexistent, : 2
2015-11-30 16:24:50 SpecialFolder.Temporary nonexistent, /Users/home 1/Documents/Light Blue Software/Light Blue/Thumbnails: 3
2015-11-30 16:24:50 SpecialFolder.Temporary nonexistent, : 4
2015-11-30 16:24:50 SpecialFolder.Temporary nonexistent, : 5
2015-11-30 16:24:50 SpecialFolder.Temporary nonexistent, : 6
2015-11-30 16:24:50 SpecialFolder.Temporary nonexistent, : 7
2015-11-30 16:24:50 SpecialFolder.Temporary nonexistent, : 8
2015-11-30 16:24:51 SpecialFolder.Temporary nonexistent, /Users/home 1/Documents/Light Blue Software/Light Blue/Logs: 9
2015-11-30 16:24:51 SpecialFolder.Temporary nonexistent, : 10
2015-11-30 16:24:51 SpecialFolder.Temporary nonexistent, : 11
2015-11-30 16:24:51 SpecialFolder.Temporary nonexistent, /Users/home 1/Documents/Light Blue Software/Light Blue/Logs: 12
2015-11-30 16:24:51 SpecialFolder.Temporary nonexistent, /Users/home 1/Documents/Light Blue Software/Light Blue/Logs: 13
2015-11-30 16:24:51 SpecialFolder.Temporary nonexistent, : 14
2015-11-30 16:24:51 SpecialFolder.Temporary nonexistent, /Users/home 1/Documents/Light Blue Software/Light Blue/Logs: 15
2015-11-30 16:24:51 SpecialFolder.Temporary nonexistent, : 16
2015-11-30 16:24:51 SpecialFolder.Temporary nonexistent, /Users/home 1/Documents/Light Blue Software/Light Blue/Logs: 17
2015-11-30 16:24:52 SpecialFolder.Temporary nonexistent, : 18
2015-11-30 16:24:52 SpecialFolder.Temporary nonexistent, /Users/home 1/Documents/Light Blue Software/Light Blue/Logs: 19
2015-11-30 16:24:52 SpecialFolder.Temporary nonexistent, /Users/home 1/Documents/Light Blue Software/Light Blue/Logs: 20
2015-11-30 16:24:52 SpecialFolder.Temporary nonexistent, /Users/home 1/Documents/Light Blue Software/Light Blue/Logs: 21
2015-11-30 16:24:52 SpecialFolder.Temporary nonexistent, : 22
2015-11-30 16:24:52 SpecialFolder.Temporary nonexistent, : 23
2015-11-30 16:24:52 SpecialFolder.Temporary nonexistent, : 24
2015-11-30 16:24:52 SpecialFolder.Temporary nonexistent, : 25
2015-11-30 16:24:52 SpecialFolder.Temporary nonexistent, : 26
2015-11-30 16:24:52 SpecialFolder.Temporary nonexistent, : 27
2015-11-30 16:24:53 SpecialFolder.Temporary nonexistent, /Users/home 1/Documents/Light Blue Software/Light Blue/Logs: 28
2015-11-30 16:24:53 SpecialFolder.Temporary nonexistent, /Users/home 1/Documents/Light Blue Software/Light Blue/Logs: 29[/quote]

First up, we’re really confused as to why f.NativePath is changing over the course of our logging.
Next, we don’t understand why SpecialFolder.Temporary doesn’t exist. It’s not Nil, it just doesn’t exist. But it’s the Temporary folder! Doesn’t it have to exist?

There are two very baffled people on this end; if anyone’s got any insights we would be delighted to hear.

Thanks,

Hamish

In addition the path returned by f.NativePath doesn’t make any sense for the TEMP path on OS X:

/Users/home 1/Documents/Light Blue Software/Light Blue/Logs

It should be something like this:

/private/var/folders/94/cjymqtbs1lq73ncqyn7f47_w0000gn/T/TemporaryItems

You can try this declare:

Declare Function NSTemporaryDirectory Lib "Foundation" () As CFStringRef Dim path As String = NSTemporaryDirectory()

Hi there,
Yes, as I say, we’re really confused why f.nativepath keeps changing. It should be as you suggest.
We may well try that declare!
Hamish

Do you know more about that user’s system? Is that in a corporate environment, is the computer managed by someone else or perhaps even boots from the network?
It’s also very unusual that the user’s home folder has a blank in its name. Maybe the user has just messed up his system too much, and has probably other strange issues as well.

Nope, it’s a ‘normal’ Mac, no network boot, nothing special, in a person’s home studio.
That space is indeed odd.