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

Approved license version is always updated to version being installed, even if current approved license is newer #111

Open
mjdetullio opened this issue Dec 16, 2015 · 7 comments
Labels

Comments

@mjdetullio
Copy link

https://github.com/neonichu/xcode-install/blob/9b08988e0ba8da6693b5961f0d23598ea584f853/lib/xcode/install.rb#L101

approve_license is always invoked on installation. This has the possibility to overwrite the approval with an older version, thereby invalidating the approval of the license for any installed Xcode newer than that version.

Steps to reproduce (assuming Xcode 7.2 and 7.0 are not installed):

  1. xcversion install 7.2
  2. DEVELOPER_DIR=/Applications/Xcode-7.2.app/Contents/Developer agvtool (or some other binary in Xcode) -- notice there is no prompt for license when using Xcode 7.2
  3. xcversion install 7
  4. DEVELOPER_DIR=/Applications/Xcode-7.app/Contents/Developer agvtool (or some other binary in Xcode) -- notice there is no prompt for license when using Xcode 7.0
  5. DEVELOPER_DIR=/Applications/Xcode-7.2.app/Contents/Developer agvtool (or some other binary in Xcode) -- notice there _is now_ a prompt to accept the license when using Xcode 7.2 OR when you're not the root user the command will fail with a rather ambiguous error agvtool: error: unable to find utility "agvtool", not a developer tool or in PATH because Xcode thinks the license has not been accepted yet

Expected:

No need to accept license for all installed Xcodes

Actual:

License must be accepted again manually for latest Xcode version in order to remove prompts for any version between the most recent Xcode installed and the latest

Suggestion:

Add logic to approve_license to ensure the value of IDEXcodeVersionForAgreedToGMLicense is less than the version being installed before updating the agreement preference.

Let me know what you think. I can work a PR if necessary.

@neonichu neonichu added the bug label Dec 16, 2015
@neonichu
Copy link
Collaborator

Sounds right, thanks for the detailed write-up. A PR would be greatly appreciated, of course :)

@timsutton
Copy link
Collaborator

I've recently noticed the same.

Also related: #71 - maybe https://github.com/neonichu/liferaft could be used to do the version comparison.

@UkuLoskit
Copy link

Btw, why isn't xcodebuild -license acceptused?

@neonichu
Copy link
Collaborator

It doesn't necessarily work, see #65

@timsutton
Copy link
Collaborator

In my experience it's always written out the license data properly to the plist, but only for the version of Xcode containing the xcodebuild binary. So running it on an older version of Xcode will cause a newer one to be no longer licensed, but not the other way around. Also, betas use separate license keys.

I recently wrote this up here: https://macops.ca/deploying-xcode-the-trick-with-accepting-license-agreements/

A quick but dirty solution is to run xcodebuild -license accept blindly on all installed Xcodes in order of ascending versions (simple but obviously not always necessary), or actually check the license status of the latest GM and Beta versions of installed Xcodes when a new installation happens, to check whether the keys in com.apple.dt.Xcode are set to the highest installed versions.

@mindrunner
Copy link

Any updates on this one?

@neonichu
Copy link
Collaborator

Not really, I would be happy to merge a PR, but since this is an edge case, I will probably not be able to dedicate time to it myself.

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

No branches or pull requests

5 participants