26

Been trying to install psycopg2 with either easy_install or pip, and the terminal gets stuck in a loop between xcrun and lipo.

sidwyn$ sudo easy_install psycopg2
Searching for psycopg2
Reading https://pypi.python.org/simple/psycopg2/
Reading http://initd.org/psycopg/
Reading http://initd.org/projects/psycopg2
Best match: psycopg2 2.5.1
Downloading https://pypi.python.org/packages/source/p/psycopg2/psycopg2-2.5.1.tar.gz#md5=1b433f83d50d1bc61e09026e906d84c7
Processing psycopg2-2.5.1.tar.gz
Writing /tmp/easy_install-dTk7cd/psycopg2-2.5.1/setup.cfg
Running psycopg2-2.5.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-dTk7cd/psycopg2-2.5.1/egg-dist-tmp-4jaXas
clang: warning: argument unused during compilation: '-mno-fused-madd'

It bounces between xcrun and lipo and is stuck forever in this loop. Would appreciate some insights on this.

I'm on OS X Mavericks 10.9, latest build.

Max
  • 1,620
  • 15
  • 22
Sidwyn Koh
  • 1,742
  • 2
  • 21
  • 29

5 Answers5

51

A more appropriate fix is:

ln /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/lipo /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo
xcrun -k lipo

Why: xfx's fix will likely break being able to use xcode-select to choose your toolchain in future versions of Xcode.

Pre- Mavericks and Xcode 5.x, /usr/bin/lipo seems to be the actual location of the actual lipo tool (try cat /usr/bin/lipo - looks like a big binary). In Mavericks / Xcode 5.x, lipo was moved to XcodeDefault.xctoolchain, and the binary at /usr/bin/lipo is a thin wrapper that appears to just call xcrun lipo (see nm /usr/bin/lipo), which in turn finds the location of lipo based on xcode-select.

Probably, new versions of xcode-select and/or Mavericks replace /usr/bin/lipo with the wrapper version. If you then try to use lipo with the 4.x toolchain xcode-select'd, it won't work, since the tool isn't contained in older versions of Xcode. Luckily, it's still included in iPhoneOS.platform for some reason, else you'd probably have to pull it from an uncorrupted <=10.8 machine.

It looks as if there was a lot of shuffling of tools between Developer/usr/bin and Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin in the 4->5 switch - it wouldn't surprise me if there were similar problems with other less-often-used command line tools as well.

Finally, the fact that xcrun hangs when it can't find a tool seems like an apple bug, plain and simple.

scztt
  • 1,053
  • 8
  • 10
  • 1
    This q should be tagged with mavericks/xcode/lipo/xcrun and probably not python/etc, as it's a build toolchain issue and not a python issue. – scztt Oct 29 '13 at 22:55
  • One other note - if lipo still hangs after the above, `xcrun -k lipo` will clear the cached (incorrect) location. And, awesomely, if you do this WHILE your build is hung, it will instantly unhang. – scztt Nov 13 '13 at 01:04
12

This one works for me:

xcode-select -–install
sudo mv /usr/bin/lipo /usr/bin/lipo.orig
sudo ln -s /Library/Developer/CommandLineTools/usr/bin/lipo /usr/bin
avdyushin
  • 1,906
  • 17
  • 21
3

I got the same problem, fixed by replace the /usr/bin/lipo with an old one from Max OS 10.7.

Update: replace /usr/bin/lipo with /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin will work. You need Xcode application or img file.

xfx
  • 1,918
  • 1
  • 19
  • 25
3

The simplest solution is probably upgrading to XCode 5.x.

Max
  • 1,620
  • 15
  • 22
  • indeed. just had to work this our with a client. They had the latest and greatest Command Line Tools installed, but an older version of XCode 4.1.x After we upgraded XCode, we no longer had this issue. very very weird. – defbyte Apr 11 '14 at 19:28
  • I'm running Mavericks and had this problem. Upgrading to XCode 6 fixed it. – tronbabylove Feb 04 '15 at 19:50
0

I restored /usr/bin/lipo from my TimeMachine backup (timestamp before updating to OSX 10.9). Then XCode 4.x worked fine, archiving did not hang any more.

Phlume
  • 3,075
  • 2
  • 19
  • 38
gtrmn
  • 1