xcrun: error: invalid active developer path, problem after zsh update for flutter
Asked Answered
A

5

18

I 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,

Adiaphorous answered 22/10, 2020 at 19:41 Comment(1)
L
45

It looks like the Command Line tools path is not set. If you have XCode then to setup the path you need to:

  1. Open XCode
  2. Open Preferences (,)
  3. Go to Locations tab
  4. For “Command Line Tools” select the current version screenshot showing preference
Lermontov answered 31/10, 2020 at 7:3 Comment(1)
Still works as of 28 Sept 2022, thanks!Falciform
T
66

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/
Timberwork answered 23/10, 2020 at 15:20 Comment(3)
Thank you! This is exactly what I needed.Orna
Ventura complains error: invalid developer directory '/Library/Developer/CommandLineTools/'Nacred
Just the first step xcode-select --install solved the issue for meQuintet
L
45

It looks like the Command Line tools path is not set. If you have XCode then to setup the path you need to:

  1. Open XCode
  2. Open Preferences (,)
  3. Go to Locations tab
  4. For “Command Line Tools” select the current version screenshot showing preference
Lermontov answered 31/10, 2020 at 7:3 Comment(1)
Still works as of 28 Sept 2022, thanks!Falciform
D
3

Download the latest Command Line Tools for Xcode and install it to solve the problem. Complete installation of Xcode is not required.

Apple Developer Download link

Dispirit answered 8/2, 2021 at 9:16 Comment(0)
R
1

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:

  1. Disable SIP (this needs to be done via recovery mode)
  2. Create a soft simlink linking your "Developer" directory (which contains the CommandLineTools directory/instance brew is searching for) by running: sudo ln -s /path/to/Developer /path/to/Xcode.app/Contents
  3. Run the simlinker built into brew, to let brew know where the CommandLineTools instance is (brew was 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 lacking
  • alias 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.

Ryals answered 2/6, 2021 at 11:37 Comment(0)
M
0

I had help from the post

You must run sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer to make Terminal start using command line tools inside Xcode

Masha answered 26/10, 2020 at 11:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.