The first time I run Terminal or start SmartGit either one is slow to start, taking up to ~30 seconds. When I look at the status bar for Terminal I see that it is stuck running some xcodebuild
command. Not sure what exactly the command is.
Does anyone know how to view which commands Terminal runs on startup? Or if anyone else had this issue? I think it is related to this question but the slow down is only first the first startup of Terminal and for ~30 seconds. Not the 2-3 seconds users reported. Subsequent runs or commands work normally.
5
Answers
Switch Apple Git to Git, the problem will go away.
Run
brew install git
to do it.Relate link:
https://blog.smittytone.net/2021/05/21/how-to-fix-xcodebuild-macos-terminal-slow-downs/
Another option is to accept the Xcode License
You can find this referring to the reference in the linked article.
I’ve tried with
sudo xcodebuild -license accept
but at start the console is still very slow and, after a reboot, I have to wait at least 15s to see the terminal.Looking around I found out that somehow it’s
nvm
that needsxcodebuild
.The slowdown was fixed changing the
nvm
default tosystem
Try
xcodebuild -runFirstLaunch
Then after it is complete, open up 2 new Terminal tabs.
Worked for me on macOS 12.6.
I found this solution over here: https://superuser.com/a/1742463/98148
This worked for me:
https://ospfranco.com/post/2021/08/05/fix-slow-terminal-start-(hanging-xcodebuild)/
context:
I used some of the other answers here, but they didn’t actually fix it for me, as initially I didn’t realize it only is slow for the first startup per restart. Following on the comment relating the problem to
nvm
, I came across an nvm GitHub issue regarding this problem. Their solution which works for me across restarts is:solution (workaround):
Add the
alias manpath=false
line before sourcingnvm.sh
in~/.zshrc
:Now restart (or however you wish to trigger the
~/.zshrc
file being resourced).notes:
This agrees with the fact that it happens per restart, i.e., per
~/.zshrc
execution. Also, for me I also have a non-system default for nvm, which corresponds to freedev’s answer, but I need a v19+ default node version for isomorphic webcrypto, so that answer isn’t acceptable.You can read through the nvm GitHub issue for a more in depth analysis. I would recommend giving the issue a thumbs up, because the rep from nvm seemed to be incredulous that it was not a localized issue to that issue’s OP. But this question has been upvoted 35 times, which clearly shows this is not the case.