Installing MacPorts on OS X 10.11 ‘El Capitan’

High Sierra Update:  If you are looking for instructions on how to manually install MacPorts onto the High Sierra GM release, check here:  Installing MacPorts on MacOS “High Sierra”

Update: MacPorts has released their official El Capitan installer. You should probably use it instead. 🙂

Update: Since people are ignoring my above comment, I have updated the below instructions to reflect the version changes reported by Chrisp in the comments.

Another year, another OS X update.  If you are like me, you've weaseled a copy of the OS X 10.11 'El Capitan' Gold Master installer, and you have started checking to see how much of your software is going to break if and when you install.  Given the issues I've had in the past, MacPorts is the very first thing I test.  🙂

The first thing I noticed is that there is no El Capitan installer for MacPorts, and the Yosemite installer will not run on OS X 10.11.  So, we are back to compiling it ourselves.  Fortunately, this goes pretty smoothly.

The first caveat is that in addition to needing access to OS X 10.11 'El Capitan' , you will need a copy of Xcode 7 (beta, RC, etc).  You won't be able to compile MacPorts for El Capitan with Xcode 6 because of changes to one or more of the header files that ship with the OS X 10.11.

The second caveat is that I did a clean install of OS X 10.11 'El Capitan', so my instructions may not adequately deal with any cruft left over by previous installs.  If you have an upgrade issue, please comment here and I'll do my best to help you out and improve the instructions.  You may want to follow the MacPorts uninstall instructions before starting the below steps.

  1. Install OS X 10.11 'El Capitan'
  2. Install Xcode 7
  3. Launch Xcode:
    1. Agree to the license.
    2. Let it install the extra components it says it needs.
    3. Quit xcode.
  4. Open a terminal window:
    1. sudo bash
    2. export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
    3. xcode-select --install
    4. cd Desktop
    5. mkdir macports
    6. cd macports
    7. curl -O https://distfiles.macports.org/MacPorts/MacPorts-2.3.4.tar.gz
    8. tar xzvf MacPorts-2.3.4.tar.gz
    9. cd MacPorts-2.3.4
    10. ./configure --enable-readline
    11. make && make install
    12. echo 'export PATH=/opt/local/bin:/opt/local/sbin:$PATH' >> ~/.profile
    13. source ~/.profile
    14. port -v selfupdate

At this point, you should be ready to start reinstalling your ports!  Wee!

If you see this error at step 4-10:

checking for Apple Foundation library... no
configure: WARNING: GNUSTEP_SYSTEM_ROOT is not defined in your environment, preventing the use of GNUstep's Foundation library
configure: error: Could not find a working Foundation implementation

It means you either have not installed Xcode 7 GM, or that you are running Xcode 7 Beta.  Xcode 6 doesn't know how to handle the changes to /System/Library/Frameworks/Foundation.framework/Headers/Foundation.h that happened with El Capitan.  The configure script is able to find the header file, but the test compile fails so it reports that the Apple Foundation library isn't there.

If you are running Xcode Beta, you can get around this by using the following command in the shell you opened above, and then going back to step 4-10:  (Thank you SadDigger for the comment on Reddit!)

xcode-select -s /Applications/Xcode-beta.app

Update 2015-09-15 11:06AM - Fixed a typo in instruction 4-3 where WordPress was converting a double-hyphen into an extended hyphen.  I have also updated it to the latest version of MacPorts, so that the final just updates the ports rather than rebuilding the whole thing. Sorry about that!

38 Replies to “Installing MacPorts on OS X 10.11 ‘El Capitan’”

  1. Works fine with OS X upgraded from Yosemite to El Capitan GM, without uninstalling macports (2.3.3).

    Step 12 is not needed. You might have to use ‘make && sudo make install’ (step 11) and ‘sudo port selfupdate’ (step 14).

    Thank you!

    1. I appreciate the feedback. Glad your upgrade worked.

      Step 4-12 is needed if you are doing a clean install; you did an upgrade and so you already had the path update in place.

      Steps 4-11 and 4-14: If you followed my instructions exactly, then at step 4-1 you put your self into a privileged shell, and so you do not need to run sudo before those commands. It doesn’t hurt, but it isn’t needed.

  2. I followed your instructions precisely as presented and experienced the exact expected results without an of the deviations mentioned.

    Thanks for the time saving contribution,
    Bob K

  3. I followed your instructions precisely as presented and experienced the exact expected results without an of the deviations mentioned.

    Thanks for the time saving contribution,
    Bob K

  4. Hi,

    Can you help me?
    I get this error when installing port BZIP2:
    —> Fetching archive for bzip2
    —> Attempting to fetch bzip2-1.0.6_0.darwin_15.x86_64.tbz2 from http://lil.fr.packages.macports.org/bzip2
    —> Attempting to fetch bzip2-1.0.6_0.darwin_15.x86_64.tbz2 from http://mse.uk.packages.macports.org/sites/packages.macports.org/bzip2
    —> Attempting to fetch bzip2-1.0.6_0.darwin_15.x86_64.tbz2 from http://nue.de.packages.macports.org/macports/packages/bzip2
    —> Fetching distfiles for bzip2
    —> Attempting to fetch bzip2-1.0.6.tar.gz from http://lil.fr.distfiles.macports.org/bzip2
    —> Verifying checksums for bzip2
    —> Extracting bzip2
    Error: org.macports.extract for port bzip2 returned: command execution failed
    Please see the log file for port bzip2 for details:
    /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_archivers_bzip2/bzip2/main.log
    To report a bug, follow the instructions in the guide:
    http://guide.macports.org/#project.tickets
    Error: Processing of port bzip2 failed

    Log:
    version:1
    :debug:main bzip2 has no conflicts
    :debug:main Executing org.macports.main (bzip2)
    :debug:main changing euid/egid – current euid: 0 – current egid: 0
    :debug:main egid changed to: 20
    :debug:main euid changed to: 502
    :debug:archivefetch archivefetch phase started at Sat Sep 19 10:05:02 CEST 2015
    :msg:archivefetch —> Fetching archive for bzip2
    :debug:archivefetch Executing org.macports.archivefetch (bzip2)
    :debug:archivefetch Can’t run archivefetch on this port without elevated privileges. Escalating privileges back to root.
    :debug:archivefetch euid changed to: 0. egid changed to: 0.
    :debug:archivefetch changing euid/egid – current euid: 0 – current egid: 0
    :debug:archivefetch egid changed to: 20
    :debug:archivefetch euid changed to: 502
    :info:archivefetch —> bzip2-1.0.6_0.darwin_15.x86_64.tbz2 doesn’t seem to exist in /opt/local/var/macports/incoming/verified
    :msg:archivefetch —> Attempting to fetch bzip2-1.0.6_0.darwin_15.x86_64.tbz2 from http://lil.fr.packages.macports.org/bzip2
    :debug:archivefetch Fetching archive failed:: The requested URL returned error: 404 Not Found
    :msg:archivefetch —> Attempting to fetch bzip2-1.0.6_0.darwin_15.x86_64.tbz2 from http://mse.uk.packages.macports.org/sites/packages.macports.org/bzip2
    :debug:archivefetch Fetching archive failed:: The requested URL returned error: 404 Not Found
    :msg:archivefetch —> Attempting to fetch bzip2-1.0.6_0.darwin_15.x86_64.tbz2 from http://nue.de.packages.macports.org/macports/packages/bzip2
    :debug:archivefetch Fetching archive failed:: The requested URL returned error: 404 Not Found
    :debug:archivefetch Privilege de-escalation not attempted as not running as root.
    :debug:fetch fetch phase started at Sat Sep 19 10:05:07 CEST 2015
    :notice:fetch —> Fetching distfiles for bzip2
    :debug:fetch Can’t run fetch on this port without elevated privileges. Escalating privileges back to root.
    :debug:fetch euid changed to: 0. egid changed to: 0.
    :debug:fetch changing euid/egid – current euid: 0 – current egid: 0
    :debug:fetch egid changed to: 20
    :debug:fetch euid changed to: 502
    :debug:fetch Executing org.macports.fetch (bzip2)
    :info:fetch —> bzip2-1.0.6.tar.gz doesn’t seem to exist in /opt/local/var/macports/distfiles/bzip2
    :notice:fetch —> Attempting to fetch bzip2-1.0.6.tar.gz from http://lil.fr.distfiles.macports.org/bzip2
    :debug:fetch Privilege de-escalation not attempted as not running as root.
    :debug:checksum checksum phase started at Sat Sep 19 10:05:11 CEST 2015
    :notice:checksum —> Verifying checksums for bzip2
    :debug:checksum Executing org.macports.checksum (bzip2)
    :info:checksum —> Checksumming bzip2-1.0.6.tar.gz
    :debug:checksum Calculated (md5) is 00b516f4704d4a7cb50a1d97e6e8e15b
    :debug:checksum Correct (md5) checksum for bzip2-1.0.6.tar.gz
    :debug:checksum Calculated (sha1) is 3f89f861209ce81a6bab1fd1998c0ef311712002
    :debug:checksum Correct (sha1) checksum for bzip2-1.0.6.tar.gz
    :debug:checksum Calculated (rmd160) is cc31bbae95e8eec259cef7627eae0c667654a339
    :debug:checksum Correct (rmd160) checksum for bzip2-1.0.6.tar.gz
    :debug:checksum Privilege de-escalation not attempted as not running as root.
    :debug:extract extract phase started at Sat Sep 19 10:05:11 CEST 2015
    :notice:extract —> Extracting bzip2
    :debug:extract Executing org.macports.extract (bzip2)
    :info:extract —> Extracting bzip2-1.0.6.tar.gz
    :debug:extract setting option extract.args to ‘/opt/local/var/macports/distfiles/bzip2/bzip2-1.0.6.tar.gz’
    :debug:extract Environment:
    CC_PRINT_OPTIONS=’YES’
    CC_PRINT_OPTIONS_FILE=’/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_archivers_bzip2/bzip2/work/.CC_PRINT_OPTIONS’
    CPATH=’/opt/local/include’
    LIBRARY_PATH=’/opt/local/lib’
    MACOSX_DEPLOYMENT_TARGET=’10.11′
    :debug:extract Assembled command: ‘cd “/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_archivers_bzip2/bzip2/work” && /usr/bin/gzip -dc ‘/opt/local/var/macports/distfiles/bzip2/bzip2-1.0.6.tar.gz’ | /usr/bin/gnutar -xf -‘
    :debug:extract Executing command line: cd “/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_archivers_bzip2/bzip2/work” && /usr/bin/gzip -dc ‘/opt/local/var/macports/distfiles/bzip2/bzip2-1.0.6.tar.gz’ | /usr/bin/gnutar -xf –
    :info:extract dyld: Library not loaded: /opt/local/lib/libintl.8.dylib
    :info:extract Referenced from: /usr/bin/gnutar
    :info:extract Reason: image not found
    :info:extract gzip: error writing to output: Broken pipe
    :info:extract gzip: /opt/local/var/macports/distfiles/bzip2/bzip2-1.0.6.tar.gz: uncompress failed
    :info:extract sh: line 1: 39315 Done(1) /usr/bin/gzip -dc ‘/opt/local/var/macports/distfiles/bzip2/bzip2-1.0.6.tar.gz’
    :info:extract 39316 Trace/BPT trap: 5 | /usr/bin/gnutar -xf –
    :info:extract Command failed: cd “/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_archivers_bzip2/bzip2/work” && /usr/bin/gzip -dc ‘/opt/local/var/macports/distfiles/bzip2/bzip2-1.0.6.tar.gz’ | /usr/bin/gnutar -xf –
    :info:extract Exit code: 133
    :error:extract org.macports.extract for port bzip2 returned: command execution failed
    :debug:extract Error code: NONE
    :debug:extract Backtrace: command execution failed
    while executing
    “portextract::extract_main org.macports.extract”
    (“eval” body line 1)
    invoked from within
    “eval $procedure $targetname”
    :info:extract Warning: targets not executed for bzip2: org.macports.activate org.macports.extract org.macports.patch org.macports.configure org.macports.build org.macports.destroot org.macports.install
    :notice:extract Please see the log file for port bzip2 for details:
    /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_archivers_bzip2/bzip2/main.log

  5. I’m not doing a clean install. Maybe that’s the problem. Anyway, things went smoothly until Step 4.14, port -v self update. I get the messages:

    Current platform “darwin 15” does not match expected platform “darwin 14”
    Error: If you upgraded your OS, please follow the migration instructions: https://trac.macports.org/wiki/Migration
    OS platform mismatch
    while executing
    “mportinit ui_options global_options global_variations”
    Error: /opt/local/bin/port: Failed to initialize MacPorts, OS platform mismatch

    I am running the GM of El Capitan and Xcode 7, which doesn’t appear to be a beta version.

    If the only recourse is to scrub existing MacPorts, is there a way of saving the ports I already have so I don’t have to try and remember to download them again?

    Thanks, slferris

    1. Current platform “darwin 15” does not match expected platform “darwin 14”

      That’s the error you get when you try to run macports components compiled for Yosemite on El Capitan. I expect you will need to clean out your old install first.

      To save your old port list, and reinstall it automagically, run this command before uninstalling MacPorts:
      port installed | awk '{print $1}' > /tmp/portlist.txt

      And then after installing a fresh copy of MacPorts, re-install your old port list with this command:
      sudo port install `cat /tmp/portlist.txt`

  6. So do you have to run macports thru the command line or is there a icon that is created when you follow these steps?

  7. Thanks for this helpful post. I forgot about MacPorts when I upgraded and it set me back a few hours to sort out this nonsense. The MacPorts project is definitely lacking elegance in this department.

  8. The Mac App Store can be confusing sometimes. It will show an update installed, but still listed as needing to be installed. I had that problem with Xcode 7…. It showed 7.0.1 as installed, but then still needing to be installed. To be sure, I checked my local version and then saw that it was still at 7.0. So I needed whatever the App Store was offering up. Attempting to install from the Updates panel did not work. I needed to go to the Xcode details page and install from there. And it takes a long time, even though the update is only a partial (was about 106MB), just to get the differences from what I already had. Just wait for it to finish, then run the “xcode-select –install” step above.

  9. “To save your old port list, and reinstall it automagically, run this command before uninstalling MacPorts:
    port installed | awk ‘{print $1}’ > /tmp/portlist.txt

    There’s a chicken-and-egg situation here. Can’t run port until the install is complete! 😉

  10. I have updated the same way as I have for the last few OS updates. Use the SVN method on the web site and it works. Takes a lot of time but works and will upgrade all your current ports.
    And yes, first steps are XCode 7.0.1 and the CLI tools. Don’t forget them!

  11. I need to run source .profie every time. what can i do to get rid of this? anybody please help me.

  12. I followed the steps given above. But when I enter the final command i.e. “port -v selfupdate” it exits with this error:

    —> Updating MacPorts base sources using rsync
    rsync: failed to connect to rsync.macports.org: Connection refused (61)
    rsync error: error in socket IO (code 10) at /BuildRoot/Library/Caches/com.apple.xbs/Sources/rsync/rsync-47/rsync/clientserver.c(105) [receiver=2.6.9]
    Command failed: /usr/bin/rsync -rtzv –delete-after rsync://rsync.macports.org/release/tarballs/base.tar /opt/local/var/macports/sources/rsync.macports.org/release/tarballs
    Exit code: 10
    Error: Error synchronizing MacPorts sources: command execution failed
    To report a bug, follow the instructions in the guide:
    http://guide.macports.org/#project.tickets
    Error: /opt/local/bin/port: port selfupdate failed: Error synchronizing MacPorts sources: command execution failed

      1. It’s not network conn issue. I come across your article when I met same error when trying to update port.

        The solution is to modify /opt/local/etc/macports/sources.conf
        from original line:
        rsync://rsync.macports.org/release/tarballs/ports.tar [default]
        to
        rsync://131.188.12.211/macports/release/tarballs/ports.tar [default]

        The IP 131.188.12.211 is got from
        nslookup rsync.macports.org

  13. I got this problem when I ran the last line.

    bash-3.2# port -v selfupdate
    —> Updating MacPorts base sources using rsync
    rsync: read error: Operation timed out (60)
    rsync error: error in rsync protocol data stream (code 12) at /BuildRoot/Library/Caches/com.apple.xbs/Sources/rsync/rsync-47/rsync/io.c(604) [receiver=2.6.9]
    Command failed: /usr/bin/rsync -rtzv –delete-after rsync://rsync.macports.org/release/tarballs/base.tar /opt/local/var/macports/sources/rsync.macports.org/release/tarballs
    Exit code: 12
    Error: Error synchronizing MacPorts sources: command execution failed
    To report a bug, follow the instructions in the guide:
    http://guide.macports.org/#project.tickets
    Error: /opt/local/bin/port: port selfupdate failed: Error synchronizing MacPorts sources: command execution failed

    please help me.

  14. by now (end of July 2016) you have to use MacPorts 2.3.4, otherwise you end up in this rsync connection error already discussed above.
    Took me a while fiddling around with all kinds of proxy settings (export http_proxy=http:// as well as set RSYNC_PROXY=…) before realizing that the base.tar URI is simply outdated in the MacPorts 2.3.3 version (this does not exist any more: rsync://rsync.macports.org/release/tarballs/base.tar) By the way: thanks Apple!

    Solution: In step 7 do this:
    curl -O https://distfiles.macports.org/MacPorts/MacPorts-2.3.4.tar.gz
    using the equivalent version number in the following ones.

    Cheers

  15. Hi, I tried your solution but when I try to run configure I get this:

    bash-3.2# ./configure –enable-readline
    checking build system type… mkdir: /tmp/cg4967-13168: Operation not permitted
    mkdir: /tmp/cg-4967: Operation not permitted
    config.guess: cannot create a temporary directory in /tmp
    configure: error: cannot guess build type; you must specify one

    Do you know what the problem is?

      1. Hi Chris,
        No, no problem with any step before /.configure
        Perhaps I should mention that I have the coretelephony bug a lot of people is reporting. The interesting thing is that it is also related to the /tmp folder
        I have also been unable to install other applications such as, Homebrew, Macports via the dmg and Xquartz

          1. Yeah, I wrote (and used) my instructions before the rootless update came out. I’m neck deep in a new job and don’t have the spare cycles to spin up a 10.11 machine, patch it up, and then work through fixing the instructions. I’m sorry. 🙁

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.