Skip to content

Fix Xcode CLT path if both CLT & Xcode is installed #17

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

RMinibaev
Copy link

@RMinibaev RMinibaev commented Apr 4, 2022

If Xcode Command Line Tools is installed at the moment of playbook execution and xcode-select path is set to CLT, then step Get Installed Xcode version would fail with xcodebuild error:

TASK [Gathering Facts] *********************************************************
ok: [localhost]

TASK [macstadium.xcode : Check if Xcode is installed] **************************
ok: [localhost] => {"changed": false, "cmd": ["mdfind", "-onlyin", "/Applications", "kMDItemCFBundleIdentifier == 'com.apple.dt.Xcode'"], "delta": "0:00:00.081954", "end": "2022-04-04 17:37:25.955265", "msg": "", "rc": 0, "start": "2022-04-04 17:37:25.873311", "stderr": "", "stderr_lines": [], "stdout": "/Applications/Xcode.app", "stdout_lines": ["/Applications/Xcode.app"]}

TASK [macstadium.xcode : Register xcode_installed] *****************************
ok: [localhost] => {"ansible_facts": {"xcode_installed": true}, "changed": false}

TASK [macstadium.xcode : Get Installed Xcode version] **************************
ok: [localhost] => {"changed": false, "cmd": "xcodebuild -version | head -n1 | cut -d \" \" -f 2", "delta": "0:00:00.015405", "end": "2022-04-04 17:37:26.360811", "msg": "", "rc": 0, "start": "2022-04-04 17:37:26.345406", "stderr": "xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance", "stderr_lines": ["xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance"], "stdout": "", "stdout_lines": []}

TASK [macstadium.xcode : Export Installed Xcode version] ***********************
ok: [localhost] => {"ansible_facts": {"xcode_installed_version": ""}, "changed": false}

TASK [macstadium.xcode : Get Candidate Xcode version] **************************
ok: [localhost] => {"changed": false, "cmd": "echo -n \"/Users/test/Downloads/Xcode_13.3.xip\" | cut -d \"_\" -f 2 | sed s/'.xip'//g", "delta": "0:00:00.013016", "end": "2022-04-04 17:37:26.744190", "msg": "", "rc": 0, "start": "2022-04-04 17:37:26.731174", "stderr": "", "stderr_lines": [], "stdout": "13.3", "stdout_lines": ["13.3"]}

TASK [macstadium.xcode : Export Candidate Xcode version] ***********************
ok: [localhost] => {"ansible_facts": {"xcode_target_version": "13.3"}, "changed": false}

TASK [macstadium.xcode : check that the xcode archive is valid] ****************
fatal: [localhost]: FAILED! => {"msg": "The conditional check 'not xcode_installed or xcode_installed_version is version(xcode_target_version, '!=')' failed. The error was: Input version value cannot be empty\n\nThe error appears to be in '/Users/test/.ansible/roles/macstadium.xcode/tasks/main.yml': line 32, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n  block:\n    - name: check that the xcode archive is valid\n      ^ here\n"}

PLAY RECAP *********************************************************************
localhost                  : ok=7    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0  

Screenshot 2022-04-04 at 17 46 49

This newly added step assures that xcode clt path is set to actual xcode installation

@RMinibaev
Copy link
Author

@ispasov please, review if possible

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

Successfully merging this pull request may close these issues.

2 participants