64

When I try to run previously working git commands, I get this:

dyld: Symbol not found: _sqlite3_intarray_bind
  Referenced from: /System/Library/Frameworks/CoreData.framework/Versions/A/CoreData
  Expected in: /opt/local/lib/libsqlite3.dylib
 in /System/Library/Frameworks/CoreData.framework/Versions/A/CoreData
git: error: unable to locate xcodebuild, please make sure the path to the Xcode folder is set correctly!
git: error: You can set the path to the Xcode folder using /usr/bin/xcode-select -switch

How can I fix this?

Paul
  • 26,170
  • 12
  • 85
  • 119
tol4trob
  • 1,187
  • 1
  • 8
  • 8

12 Answers12

163

This works for me sudo xcode-select --switch /Library/Developer/CommandLineTools/

sushilprj
  • 2,203
  • 1
  • 14
  • 19
  • 1
    I had xcode and another xcode beta. After uninstalling the beta I got "Error: Failure while executing: /usr/bin/otool -L /usr/bin/install_name_tool". Then I did this commando and it works again. – LetsGoRangers Jun 14 '16 at 08:07
  • 1
    I did `sudo xcode-select --switch /Applications/Xcode.app` but that did not solve my problem. Why did your approach solve the problem? – crisron Sep 16 '16 at 01:57
  • 1
    Dunno how you figured that out, but it worked for me too. – Edward Falk Sep 16 '16 at 05:17
  • 1
    You have to make sure the command line tools are installed, when I finally upgraded to sierra, these weren't installed - http://osxdaily.com/2014/02/12/install-command-line-tools-mac-os-x/ – chrismarx Nov 23 '16 at 02:31
  • 12
    It doesn't work for me. I got `xcode-select: error: invalid developer directory '/Library/Developer/CommandLineTools/'` – Jason Liu Oct 15 '19 at 03:46
  • 1
    I also got `xcode-select: error: invalid developer directory '/Library/Developer/CommandLineTools/'`, for me the solution was to just update the XCode app from Appstore. After that it started working. – lilline Dec 11 '19 at 11:40
  • I ran into this issue when upgrading Sierra -> Catalina and the command shared by @sushilprj fixed it for me. Thanks! – jerome Jan 27 '20 at 17:15
43

After a much googling and confusion, the following steps lead to a solution (with Xcode installed). Some might be optional, so please feel free to elaborate on this as I am not an expert on these errors.

  • download mavericks command line tools https://developer.apple.com/downloads/
  • xcode-select --install
  • sudo xcode-select -switch /Library/Developer/CommandLineTools
  • brew install sqlite3
  • commented out DYLD_LIBRARY_PATH entry in my .bashrc file
prayagupa
  • 30,204
  • 14
  • 155
  • 192
tol4trob
  • 1,187
  • 1
  • 8
  • 8
  • You don't need to download mavericks command line tools/be a developer. You can start on step 2. (assuming you have the new xcode, at least) – Jono Dec 08 '13 at 05:58
  • I'm getting OP's error when trying to install a redmine plugin after updating Command Line Tools to version 6.0 for OSX 10.9. The key takeaway on this was to run the command `sudo xcode-select -switch /Library/Developer/CommandLineTools` which fixed my error. Thanks! – Kirkland Sep 30 '14 at 17:44
  • personally i only needed steps 1-3. thanks for this info! – gdibble Nov 05 '15 at 00:03
  • I only needed step 3 – MikeF Jan 23 '16 at 23:58
  • STEP2 and STEP3 were enough for me – prayagupa Nov 20 '18 at 03:14
  • I upgraded Mac Os X from Mojave to Catalina, and got a similar error when running `git`. I develop in Intellij, not Xcode, but needed the command line tools. The first two commands above resolved this for me. – rcprcp Nov 17 '19 at 04:04
  • I had upgraded to Big Sur 11.6.3 and had the same issue as the original post. My issue was resolved by performing step 2 and 3 just as a few others here. I initially did step 3 only which prompted the error that the path given in step 2 was not an allowed path. Hopefully this helps a few others with similar but not the exact problem. – S.Jamal Jul 06 '22 at 09:54
31

On MacOS Mojave this worked for me (git 2.21.0):

xcode-select --install
sudo xcode-select -switch /Library/Developer/CommandLineTools
theandrewlane
  • 438
  • 4
  • 4
  • Thanks! Worked on Catalina as well. This is a better answer as the installation (first command) was required. – Sarang Jun 19 '21 at 07:06
14

If you have already installed Xcode, you can run the following command to determine and point to the correct location

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

Or use AppStore to install latest Xcode.

zdk
  • 1,528
  • 11
  • 17
  • `git` stopped working for me after I updated to Catalina. Updating Xcode in the App Store worked for me. Didn't need to switch anything. – Zufeng Dec 26 '19 at 07:09
12
xcode-select --install
sudo xcode-select -switch /Library/Developer/CommandLineTools

This did it for me.

aregjan
  • 121
  • 1
  • 3
9

Most likely you need to reinstall the command line tools before switching the xcode path to point there.

First install the tools

$ xcode-select --install

This will install the tools into the folder /Library/Developer/CommandLineTools.

Then point the xcode path to where the tools were installed, like this

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

Note: You can see the current xcode path with the command $ xcode-select -p. Mine was initially pointing to /Applications/Xcode.app/Contents/Developer when I was getting the error

answerzilla
  • 181
  • 2
  • 4
8

This worked for me in MacOS High Sierra (10.13.6)

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

J Knowles
  • 113
  • 2
  • 4
3

I met this error when i run the command 'git clone xxx'

dyld: Library not loaded: @rpath/libswiftCore.dylib Referenced from: /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild Reason: image not found git: error: unable to locate xcodebuild, please make sure the path to the Xcode folder is set correctly! git: error: You can set the path to the Xcode folder using /usr/bin/xcode-select -switch

Then, run the command

xcode-select -p

pointing to /Applications/Xcode.app/Contents/Developer

After run the command sudo xcode-select -switch /Library/Developer/CommandLineTools

it points to /Library/Developer/CommandLineTools

NANA
  • 51
  • 3
2

I hit this same issue running Fastlane on a fresh High Sierra installation. Solved with:

sudo xcode-select --switch /Applications/Xcode.app
Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
wanton
  • 98
  • 7
0

Maybe you should install Xcode 5.0.1 for Mavericks. Check updates.

ton
  • 1,524
  • 13
  • 10
0

This worked for me, just paste in terminal: sudo xcode-select --switch /Library/Developer/CommandLineTools/

0

I had the same problem after updating from High Sierra to Monterey. If you just updated MacOS, a simple Xcode update will do. No extra steps are needed.