skip to Main Content

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


  1. 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

    sudo xcodebuild -license accept
    

    You can find this referring to the reference in the linked article.

    Login or Signup to reply.
  2. 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 needs xcodebuild.

    The slowdown was fixed changing the nvm default to system

    nvm alias default system
    
    Login or Signup to reply.
  3. 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

    Login or Signup to reply.
  4. This worked for me:

    sudo rm -rf /Library/Developer/CommandLineTools
    sudo xcode-select --install
    sudo xcode-select -switch /Library/Developer/CommandLineTools
    

    https://ospfranco.com/post/2021/08/05/fix-slow-terminal-start-(hanging-xcodebuild)/

    Login or Signup to reply.
  5. 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:

    OK! So it appears adding this line to ~/.zshrc above the nvm lines works around the problem for now:

    alias manpath=false
    

    solution (workaround):

    Add the alias manpath=false line before sourcing nvm.sh in ~/.zshrc:

    alias manpath=false
    export NVM_DIR=~/.nvm
    source $(brew --prefix nvm)/nvm.sh
    

    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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search