xcrun: error: invalid active developer path, problem after zsh update for flutter
Solution 1
It looks like the Command Line tools path is not set. If you have XCode then to setup the path you need to:
- Open XCode
- Open Preferences (⌘,)
- Go to Locations tab
- For “Command Line Tools” select the current version
Solution 2
The error messages seem to be about Xcode CLI tools? If so, try these commands to reset it:
xcode-select --install
sudo xcode-select -s /Library/Developer/CommandLineTools/
Solution 3
If you are on macOS Catalina and want to do this via the commandline/terminal, or the above solutions haven't worked, try these steps:
- Disable
SIP(this needs to be done via recovery mode) - Create a
soft simlinklinking your "Developer" directory (which contains the CommandLineTools directory/instancebrewis searching for) by running:sudo ln -s /path/to/Developer /path/to/Xcode.app/Contents - Run the simlinker built into
brew, to letbrewknow where the CommandLineTools instance is (brewwas written by default to support both instances running in the same directory and has refused to update for logical reasons their docs explain), by running:sudo xcode-select --switch /path/to/new/simlinked/directory/for/CommandLineTools
Here's an example on my system:
- Xcode was originally located in:
/Applications/Xcode.app - Developer directory, containing CommandLineTools was:
/Library/Developer - ran:
sudo ln -s /Library/Developer /Applications/Xcode.app/Contents/ - ran:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer/CommandLineTools - refreshed shell (or open a new instance), and then ran:
brew doctor, receiving the message:Your system is ready to brew.
For any of my new clients, I will often create these two aliases for their systems:
alias xbandaid="sudo xcode-select --reset" #when permissions might be lackingalias xfix="sudo ln -s /Library/Developer /Applications/Xcode.app/Contents/ && sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer/CommandLineTools" #for the fix as described above
I place these aliases in their bash/zsh profile, which on Catalina is typically either .zshrc or .zprofile if they use ZSH, and .bashrc or .bash_profile if they use BASH.
Disclaimer: Though I have tried this and it has successfully worked on "BigSur" client machines, I am not promising this will work for you on those installations. The same goes for MacPorts and pkgsrc also known as pkgin put out by the Joyent Software/NetBSD Samsung Group folks. They all worked for my clients and me, but reader discretion is advised.
giannik28
Updated on July 27, 2022Comments
-
giannik28 11 monthsI updated my shell to zsh and when I type flutter --version I get this:
'''xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun Failed to find the latest git commit date: VersionCheckError: Command exited with code 1: git -c log.showSignature=false log -n 1 --pretty=format:%ad --date=iso Standard out: Standard error: xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun Returning 1970-01-01 01:00:00.000 instead. Flutter 0.0.0-unknown • channel unknown • unknown source Framework • revision () • 1970-01-01 01:00:00.000 Engine • revision b8752bbfff Tools • Dart 2.10.2'''WHAT SHOULD I DO? I'm not an expert in these things XD.
Kind regards,
-
newbie over 1 yearThis worked for me :) -
Jamie over 1 yearThank you! This is exactly what I needed. -
Rakesh Verma over 1 yearyou saved my day :) thanks