Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xcode 8.3 not discovered by XcodeInstall::Installer#installed_versions #203

Open
mfurtak opened this issue Mar 28, 2017 · 17 comments
Open

Comments

@mfurtak
Copy link

mfurtak commented Mar 28, 2017

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.

@timsutton
Copy link
Collaborator

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.

@mfurtak
Copy link
Author

mfurtak commented Mar 28, 2017

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

@timsutton
Copy link
Collaborator

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.

@mfurtak
Copy link
Author

mfurtak commented Mar 28, 2017

Yup, understood!

@aegzorz
Copy link

aegzorz commented Mar 28, 2017

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"

@timsutton
Copy link
Collaborator

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"

@mfurtak
Copy link
Author

mfurtak commented Mar 28, 2017

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
Copy link
Author

mfurtak commented Mar 28, 2017

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

@bjarkehs
Copy link

bjarkehs commented Mar 28, 2017

Doesn't work on my machine either.

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

@timsutton
Copy link
Collaborator

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.

@giginet
Copy link
Contributor

giginet commented Apr 3, 2017

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
Copy link
Contributor

giginet commented Apr 3, 2017

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.

@janmisar
Copy link

janmisar commented Apr 5, 2017

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

@hhanesand
Copy link

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

@mplorentz
Copy link

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

@vigneshr89
Copy link

Fixed for me with 9.1 as well.

@wrutkowski
Copy link

sudo mdutil -E /
sudo mdutil -i on /

fixed the issue for me 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants