xcode-install icon indicating copy to clipboard operation
xcode-install copied to clipboard

Xcode 8.3 not discovered by XcodeInstall::Installer#installed_versions

Open mfurtak opened this issue 7 years ago • 17 comments

Steps to reproduce:

  • Install Xcode 8.3
  • Run in irb:
>> require 'xcode/install'
=> true
>> XcodeInstall::Installer.new.installed_versions
=> []

The problem appears to be with

mdfind "kMDItemCFBundleIdentifier == 'com.apple.dt.Xcode'"

This returns nothing if you run it after installing Xcode 8.3.

mfurtak avatar Mar 28 '17 01:03 mfurtak

Is it possible that perhaps the Spotlight DB simply hadn't yet been fully updated?

I recently installed Xcode 8.3 and the mdfind query you posted returns the application path on my system. But I could see that if the install took place and the command was run immediately afterwards, that the bundle couldn't be found.

People who would do mass installs of GarageBand, for example, used to run into a case where its bundle wouldn't be registered immediately after installation, and lsregister had to be run manually to "force" registering it with LaunchServices. I realize Spotlight and LS aren't the same thing, but perhaps there's a similar thing going on here.

timsutton avatar Mar 28 '17 02:03 timsutton

OK, that's good info - thanks @timsutton. 👍

mfurtak avatar Mar 28 '17 02:03 mfurtak

Just to clarify that I didn't test the behaviour of a query immediately after an install - just hypothesizing based on prior experience with GarageBand, and also thinking that given the huge size and number of files in the Xcode bundle, that it could result in more lengthy background processing to fully scan its contents.

timsutton avatar Mar 28 '17 02:03 timsutton

Yup, understood!

mfurtak avatar Mar 28 '17 10:03 mfurtak

Seems something is a bit different with Xcode 8.3:

$ mdls -name kMDItemCFBundleIdentifier /Applications/Xcode.app`
kMDItemCFBundleIdentifier = (null)

Previous version:

$ mdls -name kMDItemCFBundleIdentifier /Applications/Xcode-8.2.1.app
kMDItemCFBundleIdentifier = "com.apple.dt.Xcode"

aegzorz avatar Mar 28 '17 11:03 aegzorz

Not here:

➜  ~ /usr/libexec/PlistBuddy -c 'Print :CFBundleIdentifier' /Applications/Xcode-8.3.app/Contents/Info.plist
com.apple.dt.Xcode
➜  ~ /usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' /Applications/Xcode-8.3.app/Contents/Info.plist
8.3
➜  ~ mdls -name kMDItemCFBundleIdentifier /Applications/Xcode-8.3.app
kMDItemCFBundleIdentifier = "com.apple.dt.Xcode"

timsutton avatar Mar 28 '17 11:03 timsutton

Just installed Xcode 8.3 on another machine, (this time keeping 8.2.1 around) and ran these tests again after having launched Xcode 8.3.

$ mdfind "kMDItemCFBundleIdentifier == 'com.apple.dt.Xcode'"
/Applications/Xcode-8.2.1.app
$ mdls -name kMDItemCFBundleIdentifier /Applications/Xcode.app
kMDItemCFBundleIdentifier = "com.apple.dt.Xcode"
$ mdls -name kMDItemCFBundleIdentifier /Applications/Xcode-8.2.1.app
kMDItemCFBundleIdentifier = "com.apple.dt.Xcode"

mfurtak avatar Mar 28 '17 13:03 mfurtak

Most other people around me have tried this experiment and seen the Xcode 8.3 path be discovered immediately 😩 #doesntworkonmymachine

mfurtak avatar Mar 28 '17 15:03 mfurtak

Doesn't work on my machine either.

$ mdfind "kMDItemCFBundleIdentifier == 'com.apple.dt.Xcode'"
(empty response)
$ mdls -name kMDItemCFBundleIdentifier /Applications/Xcode.app
kMDItemCFBundleIdentifier = (null)

bjarkehs avatar Mar 28 '17 15:03 bjarkehs

I've mostly only been using XcodeInstall to do the fetching of the dmg/xip files and not actually doing installs (so I am usually using something like xcversion install --no-install --force), so I don't exercise this code much. This seems like a Spotlight/LS bug, though.

I suppose another approach would be if XcodeInstall instead just checked installed copies located only at /Applications via paths and (for example) querying the CFBundleVersion. Since XcodeInstall doesn't give an option for installing an Xcode elsewhere, it seems like it's potentially confusing that it detects installations elsewhere and changes behaviour depending on that.

timsutton avatar Mar 28 '17 15:03 timsutton

I tried mdls. It returns different values by install methods. returns (null) when installed via Mac App Store. However, installed xip directlly, it returns com.apple.dt.Xcode. 🤔

giginet avatar Apr 03 '17 07:04 giginet

This behavior seems to be a bug. I think this issue would be fixed on next version. maybe...

We can't find Xcode by Spotlight at all.

giginet avatar Apr 03 '17 07:04 giginet

Reindexing Spotlight worked for me. No idea why, but seems to be fixed.

janmisar avatar Apr 05 '17 13:04 janmisar

I agree with @timsutton, why make this more complicated than it has to be?

hhanesand avatar Apr 10 '17 16:04 hhanesand

I ran sudo mdutil -i on / to reindex spotlight and that fixed it for me (after a few hours).

mplorentz avatar Apr 21 '17 12:04 mplorentz

Fixed for me with 9.1 as well.

vigneshr89 avatar Nov 16 '17 22:11 vigneshr89

sudo mdutil -E /
sudo mdutil -i on /

fixed the issue for me 🙌

wrutkowski avatar Dec 07 '17 16:12 wrutkowski