Mac OS X is weird sometimes

Over the last two days a bug in OS X Lion has been driving me crazy:
My 2011 Mac mini simply wouldn’t go to sleep.

I tried everything: Pressing the power button on its back, clicking the sleep item on the -menu and pressing ⌘+⌥+⏏. Nothing worked.

Then I hit the internet and started searching for solutions, this is what I tried:

  • Is some kind of sharing function was switched on? — No.

  • Where any apps preventing it it from sleeping? — Not that I could see.

  • Any weird events in the system log? — Nope.

  • Does one of my USB drives malfunction and keep it awake? — No, again.

  • Are there any network connections open that might stop it from sleeping? — No.

  • Bluetooth issues? — Nope.

I even performed a PMU and a SMC reset, with no effect.

Essentially I didn’t know what was going on and I decided to call the Apple’s support hotline: After answering all the questions by the very nice representative I was still left with no solution.

I gave the internet one last try, stumbling on the pmset -g terminal command, which prints out a log of settings for hibernation and errors if any occurred. Nothing.

Then I remembered that earlier that day I had read that someone turned screen sharing on and off again to find out if it had any effect.
I turned on screen sharing in the sharing preference pane and hit ⌘+⌥+⏏, eyes closed… The Mac mini went to sleep immediately.
I turned it off again and the mini still went to sleep as ordered.

This is one weird bug, where not having any kind of sharing functionality turned on causes the Mac to not go to sleep. Oh boy.