32

Since this morning, on my iMac (macOS High Sierra Version 10.13.6) any time I open an iTerm2 window (with Oh My Zsh installed), I see this:

iTerm2 window running xcodebuild and stuck

It seems that it's trying to run xcodebuild and it's stuck. I never get a prompt, even after waiting a long time. I've tried pressing ctrl+C to end the process, and then I see this:

iTerm2 window after pressing cmd+C

I'm not purposely trying to do anything with Xcode. I just want to use the command line. I've been working for months without this problem, and it just started today. Any suggestion for how I can resolve this and use iTerm like normal?

Paul Shryock
  • 1,309
  • 11
  • 17

5 Answers5

60

I had the similar issue. This resolved the problem:

 # sudo xcodebuild -license accept
Dharman
  • 30,962
  • 25
  • 85
  • 135
Weijian
  • 716
  • 7
  • 3
9

I have got the same issue after updating my MBP16 with Big Sur today

I have checked my xcode command tools path with xcode-select -p and I found that the path was related to an older version of xcode (10.1 in my case, I do not remember the path, maybe /Applications/Xcode_10.1.app/Contents/Developer/).

I have reinstall xcode command tools (sudo rm -rf /Library/Developer/CommandLineTools and xcode-select --install) and I have switched the xcode command tools path with this command sudo xcode-select -switch /Library/Developer/CommandLineTools

The issue is resolved now

King Julian
  • 101
  • 1
  • 3
8

I got the same issue with macOS Big Sur.

Tried all Google results and nothing works. Eventually, I found it was caused by setting Node.js v8.x as default in nvm, alias default to system will resolve the issue. Although I don't know why nvm need to run xcodebuild for Node.js v8.x.

Rainux
  • 91
  • 1
  • 2
4

Many answers but at the first start the console is still very slow (15s).

Looking around I found out that somehow nvm needs xcodebuild.

The slowdown was fixed changing the nvm default to system

nvm alias default system

Still not well clear why this is happening, I suggest to figure out trying to change the nvm configuration until you obtain the result.

freedev
  • 25,946
  • 8
  • 108
  • 125
1

The hanging I was experiencing happened only once after reboot, and consequent launches of the shell happened instantly.

I've spent hours debugging this issue. I eventually traced the hanging to homebrew's start script. My finding was that /usr/bin/git was slow at start (took 12 secs to load) for some reason and Homebrew used that binary unless another was installed. I installed a newer version of git through Homebrew using brew install git and this fixed the issue.

Investigation

I could see that the hang causes 100% CPU usage in syspolicyd and I could see a -67062 error at the end of the hang through Console.app (this error means code object is not signed at all). Unfortunately, the error log did not point me to a specific file and I had to add echos inside the brew script to isolate the exact location of the hang. It turned out to be an execution of git. Installing another version of git that would overwrite the default one fixed the problem. I used brew install git since homebrew checks its own directory first for a git binary.

I am not exactly sure how/why the code signature of /usr/bin/git is broken. It wasn't broken when I first installed Homebrew. It was somehow corrupted later on.

Mehmet Efe Akça
  • 1,132
  • 10
  • 9