77

I've been beating my head against the desk all day trying to fix this!!!

I have tried the suggested xcode-select -switch /path/to/xcode/ as suggested here but it still gives me this error!

I have now completely removed XCode 4.4 and the command line tools as well, and running the xcrun still gives me this error!

Even installing a new copy of Xcode and the command line tools produces this error!!

Result of commands..

sh-3.2# xcode-select -print-path
/Applications/Xcode.app/Contents/Developer
sh-3.2# xcrun -find
xcrun: Error: could not stat active Xcode path '/Volumes/Xcode/Xcode45-DP1.app/Contents/Developer'.           (No such file or directory)
Community
  • 1
  • 1
David
  • 1,296
  • 1
  • 15
  • 25

7 Answers7

209

Solution #1 (affects all users)

xcode-select is the answer. You are either pointing at the wrong path or you are not doing it as a root user. Try this in Terminal:

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

and then type your password.

Solution #2 (affects only you)

If

  • you don't want to sudo, or
  • you don't have superuser permissions, or
  • solution #1 doesn't work

override the DEVELOPER_DIR environment variable instead:

export DEVELOPER_DIR="/Applications/Xcode.app/Contents/Developer"

Optional: you can make this persist between login sessions by editing your .bash_profile file.

If neither solution works, post your error message.

Community
  • 1
  • 1
Aaron Brager
  • 65,323
  • 19
  • 161
  • 287
  • Also note that you no longer have to point to the Developer folder inside the app, you can just point to the app now. – Aaron Brager Aug 15 '12 at 18:41
  • 1
    @David (1) Did you try running the `xcode-select` under `sudo`? (2) `xcrun` requires a specific utility parameter. For whatever command you're trying to do, try adding the `--kill-cache` parameter, like `xc-run --kill-cache xcode-select` for example. – Aaron Brager Aug 19 '12 at 15:24
  • @Aaron I tried xcrun --kill-cache xcode-select, but it says again: could not stat active Xcode path – Shmidt Nov 19 '12 at 21:17
  • @Aaron Do you know where to find config file for that? – Shmidt Nov 19 '12 at 21:21
  • @Flink I think it's in a database, not an easy-to-edit text file, which is why they have this app. What is the output of `xcode-select --print-path`? – Aaron Brager Nov 20 '12 at 15:06
  • @Flink Also, I'm wondering if you are running an older version of the command line tools. What if you `sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer`? – Aaron Brager Nov 20 '12 at 15:08
  • @Flink To update your command line tools, go to **Xcode** -> **Preferences** -> **Downloads** -> **Command Line Tools** -> **Update**. – Aaron Brager Nov 20 '12 at 15:09
  • @Aaron xcode-select --print-path gives right path: /Applications/Xcode.app. No, I use the latest command tools... – Shmidt Nov 20 '12 at 21:43
  • @Flink the `--print-path` command should return `/Applications/Xcode.app/Contents/Developer`. Did you try `sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer`? If not, sure, give reinstallation a whirl, it shouldn't take too long. – Aaron Brager Nov 21 '12 at 16:00
  • I changed that, but problem still exists. I'll try to reinstall. Thanks anyway for helping me ;) – Shmidt Nov 22 '12 at 08:10
  • FWIW, this fixed my borked gitlab vagrant install: https://github.com/gitlabhq/gitlab-vagrant-vm – David Watson Nov 30 '12 at 21:01
  • 8
    i've tried `sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer/` and that solved the problem – AbdullahDiaa Feb 16 '13 at 10:13
  • 1
    You just helped me with the same problem after installing Xcode 5 preview. No luck with xcode-select -switch, but exporting the DEVELOPER_DIR did the trick. – Katlu Jun 19 '13 at 11:15
  • I encountered this error after I renamed my Xcode app to Xcode5 in order to distinguish it from Xcode4.6.3 in the dock. Then the recommended solution worked great, with the path set to match - i.e., /Applications/Xcode5.app/Contents/Developer – Kevin OMara Nov 08 '13 at 19:27
15

The problem is that /usr/share/xcode-select/xcode_dir_link points to an old folder, and doesn't updates when command

sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer/ is executed.

Solution: delete this link and create it manually.

Shmidt
  • 16,436
  • 18
  • 88
  • 136
7

This worked for me:

  1. XCode preferences/Locations/Command Line Tools - set to proper version and location
  2. XCode preferences/Downloads - install command line tools
Marijn
  • 10,367
  • 5
  • 59
  • 80
kombuster
  • 91
  • 2
2

Solutions above didn't help me. Removing old system links helped me. It is described here: Error: Can't run /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/ibtool (no such file)

Community
  • 1
  • 1
Mr_Vlasov
  • 515
  • 2
  • 6
  • 25
2

I'd the same error on 10.9. I didn't had XCode installed on my system and I manually updated the XCode command line tools. After that following command fixed the error for me:

sudo xcode-select -switch /
TBA
  • 293
  • 2
  • 9
1

I've seen this with only mac systems since it considers running few commands such as gcc git as system level commands and part of command line developer tools.

I had faced this after uninstalling xcode. So the solution is to either install xcode which comes pre packed with the tools or just install the tools by running xcode-select --install.

Refs http://osxdaily.com/2014/02/12/install-command-line-tools-mac-os-x/

Chinmaya Pati
  • 357
  • 3
  • 7
-11

The solution that finally worked was by reinstalling 10.8, reinstalling Xcode, and then reinstalling the command line tools.

David
  • 1,296
  • 1
  • 15
  • 25