I'm Arisa, a freelance Full-Stack & Frontend Developer living in Germany 🇩🇪.
Recently, I installed a new OS, Catalina.
But Catalina messed up a bit of my local environment...
Git command was not available somehow.
I remember when I updated to High Sierra, this also happened too.
It seems a common phenomena happens often that installing a new OS reset some commands' settings.
I figured out in the end and I'll show you what was the situation and the ways I tried out.
Just newly installed Mac OS, Catalina
Tried to push on my Github repository as usual
Got an error message says, "git: error: unable to locate xcodebuild, please make sure the path to the Xcode folder is set correctly!"
(MacBook Pro, 13-inch, Mid 2012, bought in 2012)
dyld: Symbol not found: _OBJC_IVAR_$_NSFont._fFlags
Referenced from: /Applications/Xcode.app/Contents/Frameworks/IDEFoundation.framework/Versions/A/../../../../SharedFrameworks/DVTKit.framework/Versions/A/DVTKit
Expected in: /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit
git: error: unable to locate xcodebuild, please make sure the path to the Xcode folder is set correctly!
git: error: You can set the path to the Xcode folder using /usr/bin/xcode-select -switch
Since the error log says I need to correct Xcode folder into the right path, I guessed Xcode is still in my laptop as I can see in the Applications.
Based on the source in below, I tried this command.
$ sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
But not working🤔
This time, I assumed the case my laptop recognizes Xcode is not installed somehow although I did before.
$ sudo xcode-select --switch /Library/Developer/CommandLineTools/
Not working again.
Instead, I got this error log.
xcode-select: error: invalid developer directory '/Library/Developer/CommandLineTools/'
At this point, I can't be 100% sure wether Xcode is correctly installed or not after updated the Mac OS.
But there are more options for me to try if I assume somehow Catalina made my laptop to see Xcode is not installed.
Then I installed Xcode.
$ xcode-select --install
It showed Xcode is installed with an installation pop-ups but still same error log in my terminal🤔
In the first error log, it says “You can set the path to the Xcode folder using /usr/bin/xcode-select -switch.”
Then I followed.
$ sudo xcode-select --switch /usr/bin/xcode-select
But got this response.
xcode-select: error: invalid developer directory '/usr/bin/xcode-select'
The last possibility I could think of was to install Command Line Tools from Xcode components.
Steps are in below👇
Open X Code app → it showed me need the newest version to sign in to App Store.
Install the newest Xcode
Open → started to install components automatically.
Open Developer Tool
Got to More Developer tools → Login with Apple account
Download the Command Line Tools
But in my case, Xcode was saying, “This package is incompatible with this version of macOS.”
And “The package is trying to install content to the system volume. Contact the software manufacturer for assistance.”
Basically, this process showed me failed to install.
But when I check with the Terminal, it shows I have Git now😳
$ git --version
git version 2.21.0 (Apple Git-122.2)
Pushing my repositories also works just fine.
After all, this was the solution in this case.
It was so long time ago I updated MacOS.
But I see a lot of people write they also have similar troubles when they update to the new OS.
Somehow, the Xcode disables or resets the Xcode component, Command Line Tools and changes its path after the new OS installation.
It's very incovenient for developers to spare our time extra for waiting to update the new OS and after waiting minimum an hour, then spending another time with Xcode path.
But I'd like to give a hope for the future that Xcode or Apple improves better💡