Skip to content

fix: make xcode_emulation handle xcodebuild not in the PATH#303

Merged
aduh95 merged 5 commits intomainfrom
xcodebuild-not-found
Aug 18, 2025
Merged

fix: make xcode_emulation handle xcodebuild not in the PATH#303
aduh95 merged 5 commits intomainfrom
xcodebuild-not-found

Conversation

@aduh95
Copy link
Copy Markdown
Contributor

@aduh95 aduh95 commented Aug 18, 2025

As titled, when trying to run the script in an environment that doesn't have any xcodebuild in the path, it crashes with a FileNotFoundError instead of falling back to the XCode Command Line Tools.

Comment thread pylib/gyp/xcode_emulation.py Outdated
Comment thread pylib/gyp/xcode_emulation.py Outdated
Comment thread pylib/gyp/xcode_emulation.py Outdated
Comment thread pylib/gyp/xcode_emulation.py Outdated
Co-authored-by: Chengzhong Wu <cwu631@bloomberg.net>
@cclauss
Copy link
Copy Markdown
Contributor

cclauss commented Aug 18, 2025

I liked the targeted FileNotFoundError over the more general IOError because it describes the problem we are trying to fix. Other IOErrors are unexpected and should probably be raised, but either solution should work.

@aduh95
Copy link
Copy Markdown
Contributor Author

aduh95 commented Aug 18, 2025

I liked the targeted FileNotFoundError over the more general IOError because it describes the problem we are trying to fix. Other IOErrors are unexpected and should probably be raised, but either solution should work.

I don't have a strong opinion, I would note that given all those paths have a fallback, it's probably fine to ignore those OSErrors as long as any fallback ends up working – if not, it will reach raise GypError("No Xcode or CLT version detected!"), at which point the user must address the underlining issue.

For reference, here's the list of OSErrors according to Python doc:

      ├── OSError
      │    ├── BlockingIOError
      │    ├── ChildProcessError
      │    ├── ConnectionError
      │    │    ├── BrokenPipeError
      │    │    ├── ConnectionAbortedError
      │    │    ├── ConnectionRefusedError
      │    │    └── ConnectionResetError
      │    ├── FileExistsError
      │    ├── FileNotFoundError
      │    ├── InterruptedError
      │    ├── IsADirectoryError
      │    ├── NotADirectoryError
      │    ├── PermissionError
      │    ├── ProcessLookupError
      │    └── TimeoutError

@cclauss
Copy link
Copy Markdown
Contributor

cclauss commented Aug 18, 2025

OPTIONAL: rm xcodebuild tests would be a nice addition.

@aduh95 aduh95 merged commit 8224dee into main Aug 18, 2025
112 of 114 checks passed
@aduh95 aduh95 deleted the xcodebuild-not-found branch August 18, 2025 13:22
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.

3 participants