26

I have a Mid 2015 MacBook Pro running macOS High Sierra 10.13.3.

I tried starting up a new project and none of my commands seem to work.

I always get this error:

xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), 
missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

Seems pretty straight forward, Xcode Command Line Tools missing. Except installing it seems to not work/have no effect.

I enter: xcode-select --install, press install, agree to the agreement, it downloads, installs, gives me a nice The software was installed but if I try any command again (like brew update or brew upgrade); I get the same error. (I tried rebooting, but to no effect).

How do I resolve this issue? All I could find on Google is people saying Install Xcode Command Line Tools.

8
  • Does the output of brew config outputs a value corresponding to CLT: key?
    – Nimesh Neema
    Apr 8, 2018 at 10:36
  • @NimeshNeema Nope HOMEBREW_VERSION: 1.5.14 ORIGIN: (none) HEAD: (none) Last commit: never Core tap ORIGIN: (none) Core tap HEAD: (none) Core tap last commit: never HOMEBREW_PREFIX: /usr/local CPU: octa-core 64-bit haswell Homebrew Ruby: 2.3.3 => /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby Clang: N/A Git: 2.8.1 => /usr/local/bin/git Curl: 7.54.0 => /usr/bin/curl Java: 1.8.0_77 macOS: 10.13.3-x86_64 CLT: N/A Xcode: N/A XQuartz: N/A Apr 8, 2018 at 10:41
  • As can be seen from the output, Homebrew doesn't recognise the installation of Xcode and CLT. Have you installed Xcode via DMG or from the Mac App Store?
    – Nimesh Neema
    Apr 8, 2018 at 10:45
  • I don't have Xcode (never needed it), installed CLT via the terminal as I explained in my original question. As far as I know Xcode isn't necessary for homebrew. Never had it and it always worked fine... Unless it's a new requirement? Apr 8, 2018 at 11:04
  • Yes, Xcode isn’t required to install CLT and Homebrew.
    – Nimesh Neema
    Apr 8, 2018 at 11:11

7 Answers 7

21

Okay, After a full day of attempts, re-installing homebrew and all... found a solution which I should have tried a lot earlier in all honesty. Leaving it here if anyone else has the same problem in the future:

Doing xcode-select --install showed everything as being installed correctly but I just couldn't confirm that anywhere. I downloaded the CLT as a pkg from the apple developer website (https://developer.apple.com/download/more/) and installed it the old fashioned way. CLT is now installed and homebrew is detecting it just fine.

Brew Config now:

HOMEBREW_VERSION: 1.5.14
ORIGIN: https://github.com/Homebrew/brew
HEAD: 7fd6210127f088b6ee8708a1d7f4ec2df3fc5bb4
Last commit: 6 days ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 1f9ba958e21dce9673b932cfc1f55dd155f0df69
Core tap last commit: 31 hours ago
HOMEBREW_PREFIX: /usr/local
CPU: octa-core 64-bit haswell
Homebrew Ruby: 2.3.3 => /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby
Clang: 9.1 build 902
Git: 2.8.1 => /usr/local/bin/git
Curl: 7.54.0 => /usr/bin/curl
Java: 1.8.0_77
macOS: 10.13.3-x86_64
CLT: 9.3.0.0.1.1521514116
Xcode: N/A
XQuartz: N/A

Thanks Nimesh for helping me!

6
  • 1
    i had the same issue - running xcode-select --install fixed it for me but installing CLT manually would also do the trick!
    – Lloyd
    Oct 1, 2018 at 9:28
  • This answer saved my life! After upgrading to catalina, nothing was working for me!
    – R71
    Jun 24, 2020 at 13:26
  • what does "installed it the old fashioned way." mean? Feb 7 at 21:49
  • what does it mean to "download the CLT"? Feb 7 at 21:51
  • is it possible to uninstall the command line tools and reinstall them from scratch? Feb 7 at 23:11
17

I had to check configuration of location as explained here to make it work:

You can just select command line tools from the XCode Preferences show in below screenshot.

You will be prompted for password.

7
  • 5
    It's better to include the key points of the answer here instead of just providing a link. It's also helpful if you review How to Answer on writing good answers that attract views and subsequently, up votes.
    – Allan
    Sep 15, 2018 at 11:56
  • Useful if you have xCode installed (which is not my case; don't use it and can't afford 10GB of storage on something I don't use..) my question was specific to no-xCode installed... Thanks for the answer though, could help others :) Sep 16, 2018 at 11:23
  • This was the only answer that worked for me Oct 3, 2018 at 7:53
  • This worked for me, when setting up the Glasgow Haskell Compiler! Very easy fix!
    – Woodstock
    Dec 26, 2019 at 3:27
  • This is it. Thank you very much, I would have never found that. Jan 3, 2021 at 15:31
9

If the above answer doesn't fully fix the problem you can also check Brew Doctor mine was also complaining that Xcode.app was in the wrong place and to fix suggested the fix.

sudo xcode-select -switch /Applications/Xcode.app

My /Applications folder had somehow changed from ~/ to /

2
  • what is brew doctor? Feb 7 at 21:56
  • is it possible to uninstall the command line tools and reinstall them from scratch? Feb 7 at 23:11
1

Copying answers from https://github.com/gfx-rs/gfx/issues/2309#issuecomment-506130902

In case anyone else arrives at this issue from a search:

gfx requires both Xcode and the Xcode command line tools. Even if you have the command line tools installed, you still need Xcode.

Xcode is required for the complete macOS SDK (specifically the tools for compiling Metal shaders). The command line tools are required to use the SDK without opening the Xcode app.

You might have installed the command line tools before installing Xcode. For instance, you might have set up Homebrew first. The command line tools are pointing to an incomplete SDK, rather than the one you installed with Xcode.

How to fix

  1. Install Xcode from the Apple App Store.
  2. Install the command line tools with xcode-select --install. This might do nothing on your machine.
  3. If xcode-select --print-path prints /Library/Developer/CommandLineTools
  4. then run sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer.
1
  • is it possible to uninstall the command line tools and reinstall them from scratch? Feb 7 at 23:13
1

What I suggest is to uninstall the command line tools (CLT) and re-install them the official way.

So do (source):

sudo rm -rf /Library/Developer/CommandLineTools

check it uninstalled, you should get an output as follows:

xcode-select -p

output

xcode-select: error: unable to get active developer directory, use `sudo xcode-select --switch path/to/Xcode.app` to set one (or see `man xcode-select`)

then install the command line tools (CLT) again:

xcode-select --install

then agree to it and it should download after a couple of minutes. The download should take some time. For me ~13mins.

After that your issues with PyCharm, git, brew and likely other tools will be resolved.

note you should stop getting the error:

xcrun: error: unable to load libxcrun (dlopen(/Library/Developer/CommandLineTools/usr/lib/libxcrun.dylib, 0x0005): tried: '/Library/Developer/CommandLineTools/usr/lib/libxcrun.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/lib/libxcrun.dylib' (no such file)).

Worked for me!

0

I switched to Xcode's Command Line Tools to get it working in my case. https://stackoverflow.com/a/34617930

1
  • What do you mean switch - the only command line tools have always been Xcode
    – mmmmmm
    Jul 4, 2021 at 8:25
-1

Also ran into this. Turns out homebrew had installed my Xcode cmd line tools in /usr/bin. My IntelliJ looks for the cmd line tools at /Library/Developer/CommandLineTools/usr/bin/ So what I did was cd into /Library/Developer/CommandLineTools/usr/bin/ then did a

cp /usr/bin/* ./

and my cmd line tools were copied in. After that, IntelliJ had no more complains.

1
  • It's really strange to copy all commands in /usr/bin/.
    – DawnSong
    Aug 23, 2019 at 6:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .