Mac OS X Lion hangs on boot

I've got a very grumpy Lion version... Once ever 2/3 boots it hangs
on startup...

Lion is almost booted and shows a white screen with the Apple inside.
But 15-20 minutes later the image is the same. (I never waited longer, so maybe it's still booting).

The next boot it just works again...

After inspecting the log files I see this logged on the end (the last log item of the previous boot)

Sep  5 19:12:05 MacCreature mds[48]: (Error) ImportServer: <MDSImporterWrangler: 0x7fc21bc4ddc0> still waiting for plug-in info from mdworker
Sep  5 19:12:06 MacCreature mds[48]: (Error) ImportServer: <MDSImporterWrangler: 0x7fc21bc92710> still waiting for plug-in info from mdworker

MDS seems to be the spotlight indexer...

Plugins

The message tells me its waiting for a plugin. (not which plugin).

I've tried to move all plugins I do not use. Well I only use spotlight to quickly start apps and find filenames or search textfiles. So I disabled ALL plugins:

mkdir /Library/Spotlight/Disabled
mv /Library/Spotlight/*.mdimporter /Library/Spotlight/Disabled

That went well..
Rebooting (a few times): still the same issue
Bad luck

Disabling Indexing Service

View the status of the indexing service, for all (-a) drives.

sudo mdutil -s -a

Disable indexing for all drives

sudo mdutil -a -i off

Erase all indices.

sudo mdutil -a -E

Remove the true file. Doing this 'forgets' all your spotlight setttings
WARNING: Remember all your spotlight exclusions!!

cd /Volumes/your_hard_drive_name_1
sudo rm -fr .Spotlight-V100

Turn back on indexing (And put the exclusion back on)

sudo mdutil -i on /

Disable Mobile Backups

Not required for my problem, but I don't like these mobile backups. I've got a rsync script to a local server and use an external harddisk every week.

sudo tmutil disablelocal

It seem to have worked....
Now cross my fingers. I hate Windows-like issues on my Mac!! :S


The complete failing bootlog was:

05-09-11 19:08:15,000 bootlog: BOOT_TIME 1315242495 0
05-09-11 19:08:25,000 kernel: Darwin Kernel Version 11.1.0: Tue Jul 26 16:07:11 PDT 2011; root:xnu-1699.22.81~1/RELEASE_X86_64
05-09-11 19:08:25,000 kernel: vm_page_bootstrap: 941374 free pages and 33474 wired pages
05-09-11 19:08:25,000 kernel: kext submap [0xffffff7f8072e000 - 0xffffff8000000000], kernel text [0xffffff8000200000 - 0xffffff800072e000]
05-09-11 19:08:25,000 kernel: zone leak detection enabled
05-09-11 19:08:25,000 kernel: standard timeslicing quantum is 10000 us
05-09-11 19:08:25,000 kernel: mig_table_max_displ = 72
05-09-11 19:08:25,000 kernel: AppleACPICPU: ProcessorId=0 LocalApicId=0 Enabled
05-09-11 19:08:25,000 kernel: AppleACPICPU: ProcessorId=1 LocalApicId=1 Enabled
05-09-11 19:08:25,000 kernel: calling mpo_policy_init for TMSafetyNet
05-09-11 19:08:25,000 kernel: Security policy loaded: Safety net for Time Machine (TMSafetyNet)
05-09-11 19:08:25,000 kernel: calling mpo_policy_init for Sandbox
05-09-11 19:08:25,000 kernel: Security policy loaded: Seatbelt sandbox policy (Sandbox)
05-09-11 19:08:25,000 kernel: calling mpo_policy_init for Quarantine
05-09-11 19:08:25,000 kernel: Security policy loaded: Quarantine policy (Quarantine)
05-09-11 19:08:25,000 kernel: Copyright (c) 1982, 1986, 1989, 1991, 1993
05-09-11 19:08:25,000 kernel: The Regents of the University of California. All rights reserved.
05-09-11 19:08:25,000 kernel: MAC Framework successfully initialized
05-09-11 19:08:25,000 kernel: using 16384 buffer headers and 10240 cluster IO buffer headers
05-09-11 19:08:25,000 kernel: IOAPIC: Version 0x11 Vectors 64:87
05-09-11 19:08:25,000 kernel: ACPI: System State [S0 S3 S4 S5] (S3)
05-09-11 19:08:25,000 kernel: AppleIntelCPUPowerManagement: (built 13:08:12 Jun 18 2011) initialization complete
05-09-11 19:08:25,000 kernel: PFM64 0xf10000000, 0xf0000000
05-09-11 19:08:25,000 kernel: [ PCI configuration begin ]
05-09-11 19:08:25,000 kernel: console relocated to 0xf10030000
05-09-11 19:08:25,000 kernel: PCI configuration changed (bridge=6 device=3 cardbus=0)
05-09-11 19:08:25,000 kernel: [ PCI configuration end, bridges 7 devices 19 ]
05-09-11 19:08:25,000 kernel: FireWire (OHCI) Lucent ID 5901 built-in now active, GUID 002332fffec9f878; max speed s800.
05-09-11 19:08:25,000 kernel: mbinit: done [64 MB total pool size, (42/21) split]
05-09-11 19:08:25,000 kernel: Pthread support ABORTS when sync kernel primitives misused
05-09-11 19:08:25,000 kernel: com.apple.AppleFSCompressionTypeZlib kmod start
05-09-11 19:08:25,000 kernel: com.apple.AppleFSCompressionTypeDataless kmod start
05-09-11 19:08:25,000 kernel: handsoff: os version is 10.7
05-09-11 19:08:25,000 kernel: com.apple.AppleFSCompressionTypeZlib load succeeded
05-09-11 19:08:25,000 kernel: com.apple.AppleFSCompressionTypeDataless load succeeded
05-09-11 19:08:25,000 kernel: AppleIntelCPUPowerManagementClient: ready
05-09-11 19:08:25,000 kernel: BTCOEXIST off 
05-09-11 19:08:25,000 kernel: wl0: Broadcom BCM432b 802.11 Wireless Controller
05-09-11 19:08:25,000 kernel: 5.100.98.75
05-09-11 19:08:25,000 kernel: [IOBluetoothHCIController::setConfigState] calling registerService
05-09-11 19:08:25,000 kernel: rooting via boot-uuid from /chosen: F58F69CF-CB44-3EC7-96CD-2E70F97504AA
05-09-11 19:08:25,000 kernel: Waiting on <dict ID="0"><key>IOProviderClass</key><string ID="1">IOResources</string><key>IOResourceMatch</key><string ID="2">boot-uuid-media</string></dict>
05-09-11 19:08:25,000 kernel: Got boot device = IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/SATA@B/AppleMCP79AHCI/PRT0@0/IOAHCIDevice@0/AppleAHCIDiskDriver/IOAHCIBlockStorageDevice/IOBlockStorageDriver/Hitachi HTS725050A9A364 Media/IOGUIDPartitionScheme/Mac OS X@2
05-09-11 19:08:25,000 kernel: BSD root: disk0s2, major 14, minor 2
05-09-11 19:08:25,000 kernel: Kernel is LP64
05-09-11 19:08:17,083 com.apple.launchd: *** launchd[1] has started up. ***
05-09-11 19:08:24,422 com.apple.launchd: (com.parallels.desktop.launchdaemon) Unknown key for boolean: HopefullyExitsFirst
05-09-11 19:08:24,422 com.apple.launchd: (com.stclairsoft.AppTamerAgent) Unknown key for string: Version
05-09-11 19:08:24,422 com.apple.launchd: (com.stclairsoft.AppTamerAgent) Unknown key: Version
05-09-11 19:08:26,608 UserEventAgent: starting CaptiveNetworkSupport as SystemEventAgent built Jun 13 2011 17:29:21
05-09-11 19:08:26,612 UserEventAgent: CaptiveNetworkSupport:CreateInterfaceWatchList:2788 WiFi Devices Found. :)
05-09-11 19:08:26,612 UserEventAgent: CaptiveNetworkSupport:CaptivePublishState:1211 en1 - PreProbe
05-09-11 19:08:26,612 UserEventAgent: CaptiveNetworkSupport:CaptiveSCRebuildCache:81 Failed to get service order
05-09-11 19:08:26,613 UserEventAgent: CaptiveNetworkSupport:CaptiveSCRebuildCache:81 Failed to get service order
05-09-11 19:08:26,613 UserEventAgent: CaptiveNetworkSupport:CaptivePublishState:1211 en1 - PreProbe
05-09-11 19:08:26,613 UserEventAgent: CaptiveNetworkSupport:CaptiveSCRebuildCache:81 Failed to get service order
05-09-11 19:08:26,613 UserEventAgent: CaptiveNetworkSupport:CaptiveSCRebuildCache:81 Failed to get service order
05-09-11 19:08:26,955 UserEventAgent: CertsKeychainMonitor: configuring
05-09-11 19:08:27,000 kernel: NVEthernet: Ethernet address 00:23:32:c9:f8:78
05-09-11 19:08:27,000 kernel: AirPort_Brcm4331: Ethernet address 00:23:12:54:97:49
05-09-11 19:08:27,000 kernel: IO80211Controller::dataLinkLayerAttachComplete():  adding AppleEFINVRAM notification
05-09-11 19:08:28,829 com.apple.SecurityServer: Session 100000 created
05-09-11 19:08:28,975 airportd: _processDLILEvent: en1 attached (down)
05-09-11 19:08:29,000 kernel: Created virtif 0xffffff800cc57e00 p2p0
05-09-11 19:08:29,245 com.apple.SecurityServer: Entering service
05-09-11 19:08:29,000 kernel: AGC: 3.0.7b1, HW version=1.7.3, flags:0, features:4
05-09-11 19:08:29,000 kernel: NVDANV50HAL loaded and registered.
05-09-11 19:08:29,343 UserEventAgent: CaptiveNetworkSupport:CaptivePublishState:1211 en1 - PreProbe
05-09-11 19:08:29,683 UserEventAgent: ServermgrdRegistration cannot load config data
05-09-11 19:08:30,000 kernel: AirPort: Link Down on en1. Reason 8 (Disassociated because station leaving).
05-09-11 19:08:30,000 kernel: NVDANV50HAL loaded and registered.
05-09-11 19:08:30,000 kernel: Previous Shutdown Cause: 5
05-09-11 19:08:30,000 kernel: DSMOS has arrived
05-09-11 19:08:30,382 com.apple.pfctl: No ALTQ support in kernel
05-09-11 19:08:30,382 com.apple.pfctl: ALTQ related functions disabled
05-09-11 19:08:30,538 com.apple.ucupdate.plist: ucupdate: Checked 1 update, no match found.
05-09-11 19:08:31,000 kernel: 00000000  00000020  NVEthernet::setLinkStatus - not Active
05-09-11 19:08:31,535 UserEventAgent: get_backup_share_points no AFP
05-09-11 19:08:32,000 kernel: Ethernet [nvenet]: Link up on en0, 100-Megabit, Full-duplex, Symmetric flow-control, Debug [796d,0000,0de1,0005,45e1,0000]
05-09-11 19:08:32,000 kernel: 05f5e100  00500026  NVEthernet::setLinkStatus - Active
05-09-11 19:08:32,000 kernel: Ethernet [nvenet]: Link up on en0, 100-Megabit, Full-duplex, Symmetric flow-control, Debug [796d,0000,0de1,0005,45e1,0000]
05-09-11 19:08:32,000 kernel: 05f5e100  00500026  NVEthernet::setLinkStatus - Active
05-09-11 19:08:32,000 kernel: macx_swapon SUCCESS
05-09-11 19:08:34,682 configd: bootp_session_transmit: bpf_write(en1) failed: Network is down (50)
05-09-11 19:08:34,682 configd: DHCP en1: INIT-REBOOT transmit failed
05-09-11 19:08:36,854 Parallels: Loading kernel extension  prl_hypervisor.kext
05-09-11 19:08:37,322 com.apple.usbmuxd: usbmuxd-211 built on May 16 2011 at 00:14:56 on May 16 2011 at 00:14:55, running 64 bit
05-09-11 19:08:37,322 configd: setting hostname to "MacCreature.local"
05-09-11 19:08:37,335 configd: network configuration changed.
05-09-11 19:08:40,711 systemkeychain: done file: /var/run/systemkeychaincheck.done
05-09-11 19:08:41,537 rpcsvchost: sandbox_init: com.apple.msrpc.netlogon.sb succeeded
05-09-11 19:08:43,039 com.apple.launchd: (com.apple.netbiosd[72]) Exited abnormally: Hangup: 1
05-09-11 19:08:44,906 loginwindow: Login Window Application Started
05-09-11 19:08:45,324 configd: network configuration changed.
05-09-11 19:08:46,000 kernel: NTFS driver 3.8 [Flags: R/W].
05-09-11 19:08:47,111 mds: (Normal) FMW: FMW 0 0
05-09-11 19:08:48,745 Parallels: Loading kernel extension  prl_hid_hook.kext
05-09-11 19:08:49,000 kernel: /drv/ HypApic.c:230   Host APIC  phy 0xFEE00000  lin 0xffffff80795cd000  ver 0x14
05-09-11 19:08:49,000 kernel: /drv/ HypVtd.c:3718   [vtdInit]
05-09-11 19:08:49,000 kernel: /drv/ HypVtd.c:3734   [vtdInit] VTD initialization disabled
05-09-11 19:08:49,000 kernel: /drv/ HypLowCache.c:173   Low cache initialized (6848 kB for 8 VMs on 4096 MB)
05-09-11 19:08:49,000 kernel: /drv/ HypSMBios.c:54   Failed to find SMBios entry point
05-09-11 19:08:49,000 kernel: /drv/ HypModule.c:174   Parallels IPI irq = 0 ipi = 0(0x0)
05-09-11 19:08:49,000 kernel: /drv/ HypModule.c:181   Parallels Hypervisor 6.0.12094.676494 loaded.
05-09-11 19:08:49,000 kernel: NTFS volume name BOOTCAMP, version 3.1.
05-09-11 19:08:50,049 Parallels: Loading kernel extension  prl_usb_connect.kext
05-09-11 19:08:51,000 kernel: /prl_hid/ Parallels HID Helper started.
05-09-11 19:08:55,030 Parallels: Trying to load kernel extensions, exit status: 0
05-09-11 19:08:55,034 Parallels: Starting Parallels networking...
05-09-11 19:08:55,000 kernel: nstat_lookup_entry failed: 2
05-09-11 19:08:55,215 Parallels: Loading kernel extension  prl_netbridge.kext
05-09-11 19:08:55,465 UserEventAgent: ServermgrdRegistration cannot load config data
05-09-11 19:08:55,465 UserEventAgent: ServermgrdRegistration oldConfig is nil during net changed notification
05-09-11 19:08:56,817 Parallels: Loading kernel extension  prl_vnic.kext
05-09-11 19:08:57,000 kernel: com.parallels.kext.prlnet 6.0.12094.676494 has started.
05-09-11 19:08:58,000 kernel: 0        0 AppleUSBCDC: start - initDevice failed
05-09-11 19:08:58,000 kernel: No interval found for . Using 8000000
05-09-11 19:08:58,000 kernel: No interval found for . Using 8000000
05-09-11 19:08:58,000 kernel: No interval found for . Using 8000000
05-09-11 19:08:58,000 kernel: No interval found for . Using 8000000
05-09-11 19:08:58,000 kernel: No interval found for . Using 8000000
05-09-11 19:08:58,000 kernel: No interval found for . Using 8000000
05-09-11 19:08:58,000 kernel: No interval found for . Using 8000000
05-09-11 19:08:58,000 kernel: No interval found for . Using 8000000
05-09-11 19:08:58,000 kernel: No interval found for . Using 8000000
05-09-11 19:08:58,000 kernel: No interval found for . Using 8000000
05-09-11 19:08:58,038 UserEventAgent: servermgr_certs[11] -[CertsRequestHandler(HelperAdditions) identitiesFromKeychain:]:	SecItemCopyMatching (err = -25300)
05-09-11 19:08:59,000 kernel: com.parallels.kext.vnic 6.0.12094.676494 has started.
05-09-11 19:09:00,279 mDNSResponder: mDNSResponder mDNSResponder-320.5.1 (Aug  3 2011 19:57:38) starting OSXVers 11
05-09-11 19:09:08,423 com.apple.UserEventAgent-System: SecItemCopyMatching: Het opgegeven onderdeel komt niet voor in de sleutelhanger.
05-09-11 19:09:08,435 UserEventAgent: servermgr_certs[11] -[CertsRequestHandler(HelperAdditions) identitiesFromKeychain:]:	SecItemCopyMatching (err = -25300)
05-09-11 19:09:08,435 com.apple.UserEventAgent-System: SecItemCopyMatching: Het opgegeven onderdeel komt niet voor in de sleutelhanger.
05-09-11 19:09:08,436 UserEventAgent: CertsKeychainMonitor: ready to process keychain & timer events
05-09-11 19:12:05,281 mds: (Error) ImportServer: <MDSImporterWrangler: 0x7fc21bc4ddc0> still waiting for plug-in info from mdworker
05-09-11 19:12:06,463 mds: (Error) ImportServer: <MDSImporterWrangler: 0x7fc21bc92710> still waiting for plug-in info from mdworker

Installing Ruby on Rails with Mysql on Windows

No I don't like working on Windows, but unfortunately my co-workers haven't seen the light yet.

To make the rails setup a bit easier I needed to document the installation of Ruby on Rails on Windows with a Mysql database.
The description is about Ruby 1.9.?, Rails 3.0, Mysql 5.5 with the mysql2 gem.. and a lot of gems that got installed and compiled via "bundle install"

Here's a raw extract of the document I build:

1. Install MySQL

In our situation MySQL was installed. But you should install MySQL with development files. (C++ headers and Libraries).
Just download the Community Server at http://mysql.com/.

2. Install Ruby

Install the base Ruby version. Download the installer at http://rubyinstaller.org/
Run the installer and check the following items:

  • Add Ruby executables to your PATH
  • Associate .rb and .rbw files with this Ruby Installation

3. Install DevKit

Because a lot of Ruby plugins make use of Native extensions you need a compiler. For windows there's devkit to the rescue. Download it at rubyinstaller: http://rubyinstaller.org/.

Extract this to (for example) c:/devkit (this text assumes this location)
Open a command prompt: (cmd.exe) and enter the following commands.

cd c:/devkit 
ruby dk.rb init

DevKit wil probably find your ruby installation. But to make sure check the file c:/devkit/config.yml. It should contain the path of your Ruby installation:

--- 
- C:/Ruby192

This step installs (or updates) an operating_system.rb file into the relevant directory needed to implement a RubyGems pre_install hook and a devkit.rb helper library file into \lib\ruby\site_ruby. NOTE: you may need to use the –force option to update (with backup of the originals) the above mentioned files as discussed at the SFX DevKit upgrade FAQ entry.

Test the Devkit installation Confirm your Ruby environment is correctly using the DevKit by running.

gem install rdiscount --platform=ruby

RDiscount should install correctly and you should see:

Temporarily enhancing PATH to include DevKit... in the screen messages.

After this double check if it works by running:

ruby -rubygems -e "require 'rdiscount'; puts RDiscount.new('**Hello RubyInstaller**').to_html" 

to confirm that the rdiscount gem is working. (This should generate HTML)
(More info: https://github.com/oneclick/rubyinstaller/wiki/Development-Kit )

4. Install Git

If you not already have installed git, please do it. You will like it!
Git is required for many plugins so you need it.

  • download git at http://code.google.com/p/msysgit/ (choose a version I don't know :P, the latest .exe ?? )
  • execute the installer, select the following options:
    • check “Run Git and included tools from the windows command prompt” (Select the option with the red letters that scream "don't pick me" :P )
    • checkout-as-is and commit-as-it.

5. Install Rails with the mysql2 plugin

Next install Ruby on Rails. (We don't install/generate the docs)

gem install rails --no-ri --no-rdoc

6. Install the mysql2 gem

To build mysql2 support do this: (Point the paths to your MySQL install directory!)

NOTE: When using a 64bit version of windows you probably run into issues. Thanks for mentioning Luis! (Read more about it: http://blog.mmediasys.com/2011/07/07/installing-mysql-on-windows-7-x64-and-using-ruby-with-it/ ).

gem install mysql2 -- '--with-mysql-lib="c:\Program Files\MySQL\MySQL Server 5.5\lib" --with-mysql-include="c:\Program Files\MySQL\MySQL Server 5.5\include"'

(Mysql5.1 seems to have the path: c:\Program Files\MySQL\MySQL Server 5.1\lib\opt)

Fix up Bundler (the gem management tool) to know what the mysql2 gem build settings need to be..
Else you're "bundle install" will fail when installing or updating the mysql2 gem!!

bundle config build.mysql2 '--with-mysql-lib="c:\Program Files\MySQL\MySQL Server 5.5\lib" --with-mysql-include="c:\Program Files\MySQL\MySQL Server 5.5\include"'

As soon as you start using this installation you could get errors like 'libmysql.dll not found.
To solve this copy this file from the mysql-installation/lib directory to the ruby/bin directory.

Slightly Unrelated, install the Rails app

Pull the rails app from git. (Or copy it). And run bundler install to install all gems..

cd /rails/app
bundle install 

I've recieved the following error when doing this:

Resolving deltas: 100% (3434/3434), done.
Checking out files: 100% (85/85), done.
Fetching source index for http://rubygems.org/

Could not find devise-1.4.0 in any of the sources

I seems that devise was updated and the specific version in Gemfile.lock wasn't available anymore.
You can Force the installation of this updated package

bundle update devise

These were my steps to build a working rails environment under windows...
Enough of windows, Now back to my Mac :P

MySQL Concat method can make string searching case-sensitive

I have the following table-structure in the database.
An integer column for the number and a varchar as the prefix.

billings:

billing_prefix VARCHAR(200)
billing_nr     INTEGER NOT NULL
.. and more field, but unimportant for this example

The following record is in the database:

billing_prefix: FatOrders-
billing_nr    : 42

The complete billing number is represented to the client as "FatOrders-42".
Now I have a application that enables the user to search the list with a string. (on several fields)
A client searching for 'fat' results in the following query:

SELECT * FROM billings WHERE CONCAT( billing_prefix, billing_nr ) LIKE '%fat%'

No results..
This is not the behaviour I need :P

Mysql tells me this:

If all arguments are nonbinary strings, the result is a nonbinary string. If the arguments include any binary strings, the result is a binary string. A numeric argument is converted to its equivalent binary string form

An simple solution is to modify the query to this one:

SELECT * FROM billings WHERE CONCAT( billing_prefix, CAST( billing_nr AS char) ) LIKE '%fat%'

Vi trick to remember

A few days ago I needed to change the line endings of a text file on a Mac. This Mac did not have Textmate (of course).
I guess every unix system has vi:

:set fileformat=unix
:w

that simple :P

btw. This fix, depends on a fileformats setting (available on mosts systems). When there's no fileformat setting the following command can be given:

:%s/<ctrl>-v<enter>//

Freebsd – Broken Ruby Installation After Update

Yesterday I did a Ruby update of my Freebsd ports.
It mentioned Ruby needed to be updated. I always thinks this is Scary because I have several sites depending on the my Ruby installation.
You need to update once in a while, so I just upgraded it...

portupgrade -bapi

Today I saw my mysql-backup-cron Ruby script gave the following error:

mysql_backup.rb:3:in `require': no such file to load -- rubygems (LoadError)
	from mysql_backup.rb:3:in `<main>

WTF. I tried to run a rake task of my Rails apps.. The same error...

The gems still seem work. The command below nicely showed my Gems.

gem list 

After trying to reinstall the rubygems port which didn't do a thing.
I found the solution was to REINSTALL RUBY completely.

cd /usr/lang/ruby18
make 
make deinstall
make install clean

BTW. My Rails apps were not affected because they run in an RVM environment ...