Unable to get MacPort functionality after installing Xcode 4.3

XcodeOsx Lionxcode4.3Macports

Xcode Problem Overview


I am having trouble getting MacPorts to function properly. I just installed OSX Lion 10.7.3 I downloaded and installed MacPorts first, and then after reading the requirements, I downloaded Xcode4.3 from the App Store, and then installed it. I launched Xcode and it looks to be operational and functional. However when I attempted to port with MacPorts, it gave me this error message(excerpt):

Warning: xcodebuild exists but failed to execute
Warning: Xcode does not appear to be installed; most ports will likely fail to build.

I followed the advice from:

https://stackoverflow.com/questions/7442447/how-do-i-install-additional-packages-for-xcode-on-osx-lion-to-allow-macports-to

and installed command_line_tools_for_xcode from the Preferences within Xcode. I closed Xcode, and again got the errors:

$ sudo port install libsocketsPassword:
Warning: xcodebuild exists but failed to execute
Warning: Xcode does not appear to be installed; most ports will likely fail to build.
--->  Computing dependencies for libsockets
--->  Dependencies to be installed: openssl zlib
--->  Extracting zlib
Error: Couldn't determine your Xcode version (from '/usr/bin/xcodebuild -version').
Error: 
Error: If you have not installed Xcode, install it now; see:
Error: http://guide.macports.org/chunked/installing.xcode.html
Error: 
Error: Target org.macports.extract returned: unable to find Xcode
Error: Failed to install zlib
Log for zlib is at: /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_archivers_zlib/zlib/main.log
Error: The following dependencies were not installed: openssl zlib
Error: Status 1 encountered during processing.

I am uncertain where to go next with this. How do i trouble shoot my Xcode and MacPort interface?

Xcode Solutions


Solution 1 - Xcode

In theory this should work if you have Xcode4.3 installed (in /Applications):

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

(And you've installed the optional command line tools)

Solution 2 - Xcode

Everything will start working fine after installation of "Command Line Tools for Xcode" package. You can get it from here: https://developer.apple.com/downloads/index.action#

Solution 3 - Xcode

Please see the MacPorts migration instructions for Xcode 4.3.

The instructions are pretty involved. You need to run xcode-select to set a new tools path, update developer_dir in macports.conf (as described by Henk Poley), re-install MacPorts (ouch), and finally uninstall and re-install all of your ports (double ouch).

Edit: libpvx still wouldn't install after the above. Two extra steps were required:

  1. sudo ln -s /Developer /
  2. sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs /SDKs

YMMV if you have different ports installed!

Solution 4 - Xcode

Also in /opt/local/etc/macports/macports.conf change the line with developer_dir to point to / instead of /Developer.

Solution 5 - Xcode

After

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

I also had to run

sudo xcodebuild -license

and accept the licence

Solution 6 - Xcode

Here is a solution that has worked for me:

  1. Install Command Line Tools for Xcode

     Xcode -> Preferences -> Downloads
    
  2. Help MacPorts find the right Xcode folder

     sudo /usr/bin/xcode-select -switch /Applications/Xcode.app
    
  3. Create symbolic links for clang compilers as they now live elsewhere

     sudo ln -s `which clang` /Applications/Xcode.app/Contents/Developer/usr/bin/
     sudo ln -s `which clang++` /Applications/Xcode.app/Contents/Developer/usr/bin/
    

Solution 7 - Xcode

Try using trunk, there's no release supporting Xcode 4.3 yet.

Solution 8 - Xcode

Setting the developer path in /opt/local/etc/macports.conf works for me,

developer_dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain

since most of the compilers are stored there now instead of /usr/bin under Developer.

Solution 9 - Xcode

None of this works for me. Wait for macports to release a new version that officially supports XCode 4.3+

Solution 10 - Xcode

sudo mv /usr/bin/xcodebuild /usr/bin/xcodebuild.old
sudo ln -s /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild /usr/bin/xcodebuild 

Solution 11 - Xcode

Starting with Xcode 4.3, the command-line build tools are not installed by default. Launch Xcode, open the Preferences, and go to the Downloads tab. From there you should have an option to install the command-line tools.

You can also download them from the web here: https://developer.apple.com/downloads/index.action

Disclaimer: I haven't installed Xcode 4.3 yet. I have only read about it on the web.

Solution 12 - Xcode

As of 27/2/2012, the official suggestion from MacPorts seems to be to not use XCode 4.3 and instead use 4.1 through 4.2.1, which can be downloaded from Apple.

There is a bug ticket which might be useful to follow the evolution of this.

Incidentally, and as reported in my comment #11 in that bug report, I am able to build ports without warnings by using the 2 most sane-looking suggestions found in this question: sudo /usr/bin/xcode-select -switch /Applications/Xcode.app/Contents/Developer and changing developer_dir in /opt/local/etc/macports/macports.conf to /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain

Solution 13 - Xcode

I have macports installed without admin/root privileges, so I was unable to test the xcode-select answers. However, I observed that Pall Melsted's answer worked, but not initially. What I found out was that I had not accepted the Xcode 4.5 license agreement!

If you have just installed Xcode for the purposes of macports, and you haven't accepted the Xcode license yet, you might get the error presented by the original post. When I checked my Xcode version using /usr/bin/xcodebuild -version, I was given the prompt to read and accept the license. After doing so, and after having made the changes suggested by Pall to the macports.conf developer_dir, it all works now.

Solution 14 - Xcode

As alternative: you can make downgrade of Xcode to 4.2.1 version. DMG of Xcode 4.2.1 placed here: https://developer.apple.com/downloads/index.action

After this MacPorts became works fine for me.

Solution 15 - Xcode

This is fixed in MacPorts 2.0.4.

To upgrade:

  1. Download MacPorts 2.0.4 from the install site or run sudo port selfupdate.
  2. Run the MacPorts migration described here to reinstall all ports. This is painful but required to get back to a working state.

Solution 16 - Xcode

You should definitely run sudo xcode-select -switch /Applications/Xcode.app like everyone here says, that'll fix many problems, but certainly not all.

Afaik, all the remaining problems exist within the configuration information for various packages. You might simply reinstall MacPorts as described in the https://trac.macports.org/wiki/Migration">migration instructions, but I found another solution.


You should begin finding all effected port files using commands like grep /Developer/ ..., after executing sudo bash and cd /opt/local naturally.

You should identify all effected ports by using port provides ..., which I piped through sed and sort | uniq. You could simply reinstall all these ports using either port -n upgrade --force ... or separate port uninstall ... and port install ... commands.

I recommend using one large port -n upgrade --force ... command to avoid duplicate rebuilds of dependencies, using the separate uninstall and install commands afterwards.

There are of course various ports for which /Developer exists only inside text config files, meaning you can fix them manually with sed -i -e 's/\/Developer//g' ..., but you cannot do so with binaries obviously.

I'm afraid you must at minimum rebuild all your Python and Perl installations, making this upgrade an ideal time to clean out packages that depend upon older versions, ala python26 and perl5.8.

There are several technically effected ports I decided against rebuilding like fuse4x-kext, who contained /Developer inside Library/Extensions/fuse4x.kext/Contents/MacOS/fuse4x but hasn't prevented sshfs from working correctly.

Solution 17 - Xcode

I had initially installed xcode 3.2.2, after which I installed 4.3. When I ran the xcode-select, I still got the same error about no xcode project in /Applications. I then dug into the /usr/bin/xcodebuild script and found out that this was working correctly, and another instance of xcodebuild (the one installed with xcode 4.3, not the one in /usr/bin) was being run and returning the error:

xcodebuild: error: The directory /Applications does not contain an Xcode project.

It seems the /usr/bin/xcode-select does not work for xcode 4.3, (it's compiled so you can't really see why it's not working). Strings doesn't give any clues. Good thing osx has strace.. oh wait.

Anyways, the best I could do was modify /opt/local/etc/macports.conf and uncomment the line containing the path to the xcode installation. That seems to fix my problem for the most part.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJasonView Question on Stackoverflow
Solution 1 - XcodegeowarView Answer on Stackoverflow
Solution 2 - XcodePavel FerenczView Answer on Stackoverflow
Solution 3 - XcodegmcnaughtonView Answer on Stackoverflow
Solution 4 - XcodeHenk PoleyView Answer on Stackoverflow
Solution 5 - XcodeGreg AllenView Answer on Stackoverflow
Solution 6 - XcodeHarish NarayananView Answer on Stackoverflow
Solution 7 - XcodeClemens LangView Answer on Stackoverflow
Solution 8 - XcodePall MelstedView Answer on Stackoverflow
Solution 9 - XcodeChristoph DwertmannView Answer on Stackoverflow
Solution 10 - XcodehenryseView Answer on Stackoverflow
Solution 11 - Xcoderob mayoffView Answer on Stackoverflow
Solution 12 - Xcodehmijail mourns resigneesView Answer on Stackoverflow
Solution 13 - XcodesvoharaView Answer on Stackoverflow
Solution 14 - XcodenpubView Answer on Stackoverflow
Solution 15 - XcodeAdamView Answer on Stackoverflow
Solution 16 - XcodeJeff BurdgesView Answer on Stackoverflow
Solution 17 - XcodesiestaView Answer on Stackoverflow