xcrun can't find Xcode path

M.Y. picture M.Y. · Jan 15, 2013 · Viewed 32.1k times · Source

Mac OS X 10.8.2
Xcode 4.5.2 (installed at /Applications/Xcode.app)

Tried
xcode-select -switch /Applications/Xcode.app
After that
xcode-select -print-path
outputs correct path (/Applications/Xcode.app). But
xcrun -find gcc
fails with error
xcrun: Error: could not stat active Xcode path '/Developer/Xcode.app/Contents/Developer'. (No such file or directory).

Update 1:
Here are permission specifiers

ls -l /Applications/Xcode.app  

total 0
drwxr-xr-x@ 16 my admin 544 Oct 30 23:38 Contents

ls -l /Applications/Xcode.app/Contents  

total 24
drwxr-xr-x@ 8 my admin 272 Oct 30 23:30 Applications
drwxr-xr-x@ 9 my admin 306 Oct 30 23:36 Developer
drwxr-xr-x@ 5 my admin 170 Oct 30 23:30 Frameworks
-rw-r--r--@ 1 my admin 15289 Oct 19 14:22 Info.plist
drwxr-xr-x@ 3 my admin 102 Aug 5 08:03 Library
drwxr-xr-x@ 3 my admin 102 Oct 30 23:10 MacOS
drwxr-xr-x@ 16 my admin 544 Oct 30 23:37 OtherFrameworks
-rw-r--r--@ 1 my admin 8 Oct 19 14:22 PkgInfo
drwxr-xr-x@ 56 my admin 1904 Oct 30 23:36 PlugIns
drwxr-xr-x@ 52 my admin 1768 Oct 30 23:46 Resources
drwxr-xr-x@ 17 my admin 578 Oct 30 23:46 SharedFrameworks
drwxr-xr-x@ 4 my admin 136 Oct 17 21:50 XPCServices
drwxr-xr-x@ 3 my admin 102 Oct 30 23:10 _CodeSignature
-rw-r--r--@ 1 my admin 523 Oct 30 23:10 version.plist

ls -l /Applications/Xcode.app/Contents/Developer  

total 0
drwxr-xr-x@ 3 my admin 102 Aug 5 07:29 Documentation
drwxr-xr-x@ 7 my admin 238 Dec 20 21:09 Library
drwxr-xr-x@ 7 my admin 238 Oct 30 23:46 Makefiles
drwxr-xr-x@ 5 my admin 170 Oct 30 23:28 Platforms
drwxr-xr-x@ 3 my admin 102 Oct 10 01:37 Toolchains
drwxr-xr-x@ 22 my admin 748 Oct 30 23:31 Tools
drwxr-xr-x@ 7 my admin 238 Oct 30 23:46 usr
Please help.

Answer

M.Y. picture M.Y. · Jan 15, 2013

Fixed! In terminal:

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

Explanation:
While reading man xcrun I noticed that there is DEVELOPER_DIR environment variable that takes precedence of xcode-select. So here we are setting that variable to correct path.