ChatGPT解决这个技术问题 Extra ChatGPT

xcrun: error: active developer path ("/Applications/Xcode.app/Contents/Developer") does not exist

I'm having xcode issues when I try to use brew and git:

xcrun: error: active developer path ("/Applications/Xcode.app/Contents/Developer") does not exist, use xcode-select --switch path/to/Xcode.app to specify the Xcode that you wish to use for command line developer tools (or see man xcode-select)

I can type xcode-select and it shows that the command exists. When I type xcode-select -p it shows:

/Applications/Xcode.app/Contents/Developer

but when I do which xcode-select, it gives me:

/usr/bin/xcode-select

I've tried to use the command switch and install again via Apple Developer site but none of these options have work so far... How can I fix this?


C
CopsOnRoad

I tried that and it didn't work but I found the answer. I just had to reset the developer's path:

$ sudo xcode-select --reset

Now everything is normal


--reset normally this must be run as root
Thanks. I had uninstalled xcode and installed just the command line tools because I didn't need the whole xcode package on my mac with limited space. However, I was still unable to use commands such as gcc, but after running this command, it works like a charm
I just tried it; now I'm getting "SDK "macosx" cannot be located" lol
--reset works well for me. I need only the xcode cli for php development. So I decided to remove the complete xcode from my mac, then I downloaded only the xcode CLI installer(about 170MB). After I upgrade the installed xcode CLI via app store, and applied sudo xcode-select --reset, I am able to use brewand other command line tools such as git like before. Thanks.
Is there any danger in using --reset?
H
Harjot Singh

Mostly this error occurs when you have installed a newer version of xcode. And the command line tools are yet to be initialized.

To resolve this: Go under Xcode Preferences > Locations (tab) > And the bottom options is Command Line Tools. Please select the Xcode version for tools.

Example (For Xcode 10.0 (10A255) ): Go under Xcode Preferences > Locations (tab) > And the bottom options is Command Line Tools. Select Xcode 10.0 (10A255).

For more details please see the attached image. Hope it helps.

-- Thanks

https://i.stack.imgur.com/6SEUD.png


this answer is best
I already see it as shown in the above image, but I still see the same error on my setup. I even tried resetting. Any idea? I
To do this programmatically (I had the error because I uninstalled Xcode), sudo xcode-select --switch /Library/Developer/CommandLineTools (needs to be run as root)
I had to restart my IDE after I did this and then it worked.
This does the magic for me. Thank you
J
José Gil Ramírez

In my case, I had uninstalled Xcode and then issues with git cli started. I solved the problem running the following commands:

$ sudo xcode-select -r
$ sudo xcode-select --switch /Library/Developer/CommandLineTools

and then validating new path with:

$ sudo xcode-select -p

Hope this helps!


Worked for me after uninstalling xcode, saved my day
This one solved the issue for me, the more voted solutions didn't, thanks Jose!
I was facing issues on Android Studio after I uninstalled XCode. Worked for me. I also had to restart Android Studio after using these commands.
Worked for me! Spotted this issue after uninstalling Xcode (OSX High Sierra).
B
Bharath Kumar

I have faced the same issue as I have uninstalled the XCode abruptly, running the below command (from Terminal) helped me to resolve this.

sudo xcode-select -switch /

Check this link also if you have any other error. github.com/Homebrew/legacy-homebrew/issues/23500
This worked for me. The problem was I uninstalled xcode in my mac. The command line is somehow still tied to xcode. So I went to ~library/Developer and deleted all folders and ran this command.
This worked for me also. This is even a better solution for someone who does not want to install XCode
this work for me also
A
Amit Kumar PRO

This error coming because xcode get deleted, corrupt or moved. In my case i removed xcode from my Mac and faced the same issue.

I fixed it by simple two steps

Open Terminal Simply run following command

sudo xcode-select -r

And now error has resolved. Hope it will helpful.


It works for MacOS 12.4
G
Guilherme Silva Sousa

Use this:

sudo xcode-select -switch /

This should solve the problem.


Thank you @bruceparker this was the only option which worked for me on Mojave 10.14.2
Check this link also if you have any other error. github.com/Homebrew/legacy-homebrew/issues/23500
this was the only solution that worked for me on Catalina
T
Tobi Nary

How about what the error suggests? Did you try that?

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

That should do the trick.


--switch must be run as root
N
Nikolay Ignatyev

For me it helps to install Xcode CLI xcode-select --install after uninstalling XCode (I don't develop for the OSx or iOS)

Then I could successfully build downloaded source with make


This is what worked for me, after uninstalling Xcode. Many thanks!
M
Mir Mahfuz

Try error suggestion :

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

And Then test Git Executable Path.

https://i.stack.imgur.com/cyalZ.png


V
ViktoR

In my case such error occurred after I has tried to symbolicate crash report, and according to a manual, entered command export DEVELOPER_DIR=”/Applications/Xcode.app/Contents/Developer”

I tried some proposed here solutions but nothing helped.

Then I realized that I have added an environment variable DEVELOPER_DIR to my terminal and this led to error: "xcrun: error: missing DEVELOPER_DIR path:"

Then I've just reboot my terminal, that cleaned the environment variable and the error disappeared.

(FYI: environment variables may be checked with printenv command in terminal)


This was it for me too.
J
Johann8

I had the same problem and had to remove completely Developer tools, and reinstall:

$ rm -rf /Library/Developer/CommandLineTools
$ xcode-select --install

Tip: because Xcode had been improperly uninstalled, I had to manually (re)move the Xcode app, too:

$ mv /Applications/Xcode.app/ /Applications/Xcode.app.bak