Installing MacPorts on MacOS “High Sierra”

Update: The official MacPorts installer is out. Go get it! https://www.macports.org/install.php

Another year, another OS X update. I assume you are here because you downloaded the High Sierra GM from Apple, and were disappointed that there isn’t a MacPorts installer yet.  While I am sure they will release it soon, perhaps we can get you over the hump so you can beat up High Sierra before the official drop date.  If you are comfortable compiling software by hand, we should be able to get thru this easy-peasy.

I am doing this on a clean install of High Sierra. If you are attempting an upgrade from any previous version, your process may vary in unexpected ways.  You will want to make sure you’ve downloaded the latest version of Xcode, and you should probably follow the MacPorts uninstall instructions so you have less cruft around that could interfere with the process.  If you have an upgrade issue, please comment here and I’ll do my best to help you out and improve the instructions.

This is my first pass at getting it running.  I’m going to share all my steps.  One or two things I do might be unnecessary, and could be removed later if I refine the process; but I promise I wouldn’t have hit the Publish button if the overall process didn’t work.

 

  1. Install MacOS “High Sierra”
  2. Connect to the internet
  3. Install Xcode 9 from the App Store.
  4. Launch Xcode:
    1. Agree to the license.
    2. Let it install the extra components it says it needs.
    3. Quit xcode.
  5. Open a terminal window:
  6. sudo bash
  7. xcode-select --install
  8. When the pop-up launches, install the command line tools.
  9. cd ~/Desktop
  10. mkdir macports
  11. cd macports
  12. curl -O https://distfiles.macports.org/MacPorts/MacPorts-2.4.1.tar.gz
  13. tar -xzvf MacPorts-2.4.1.tar.gz
  14. cd MacPorts-2.4.1
  15. ./configure --enable-readline
  16. make
  17. make install
  18. echo 'export PATH=/opt/local/bin:/opt/local/sbin:$PATH' >> ~/.profile
  19. source ~/.profile
  20. port -v selfupdate

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

After manually installing MacPorts with the above instructions I was able to install subversion and wget, which are my usual two first validation tests.  Subversion alone has a total of 33 dependencies alone, and combined they have 135 dependent packages; which does a pretty good job of verifying MacPorts is working.

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!

MacPorts on Mavericks

If you found this page looking for help compiling MacPorts for OS X 10.11 El Capitan, please check out this post.

FINAL UPDATE: 2013-10-26 – The Official MacPorts installer for Maverics has been released, so there is no longer a need to jump through hoops. Please visit the MacPorts Download page to get the official version.

If you are a bleeding edge lunatic who has installed Mavericks before the first patch release, you may have realized you can’t install any new MacPorts.  You can search ports, but nothing will install.  No worries, I can help.  🙂

Note:  These instructions have evolved a bit since they were first posted, prior to the official release.  If you visited before and had problems, try again now.  These instructions assume you have already installed Mavericks.

  1. Follow steps 1, 2 & 3 of the Migration page:  https://trac.macports.org/wiki/Migration
  2. Follow the Uninstall instructions:  https://www.macports.org/guide/chunked/installing.macports.uninstalling.html
  3. Install Xcode from the App Store
  4. Launch XCode, agree to the license terms, and enter your password in the auth dialog box.
  5. Go to Preferences/Downloads
  6. Select “Check for and install updates automatically” and then click “Check and Install Now”
  7. Open a Terminal window:
    ## Reset your path, in case you have a previous install that 
    ## might bugger the configure. (Thanks Rainer)
    export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
    
    ## Install Xcode CLI. Install dialog should open up and auth 
    ## the install.  (Thanks Drew, and others)
    xcode-select --install 
    
    ## Fetch MacPorts source code
    curl -O https://distfiles.macports.org/MacPorts/MacPorts-2.2.0.tar.bz2
    
    ## Uncompress source and change to the source directory
    tar jxvf MacPorts-2.2.0.tar.bz2
    cd MacPorts-2.2.0
    
    ## Configure the make file for MacPorts (Thanks Clemens)
    ./configure --enable-readline  
    
    ## Compile MacPorts
    make
    
    ## Install MacPorts
    sudo make install
    
    ## Fix your path (Thanks Peter)
    echo 'export PATH=/opt/local/bin:/opt/local/sbin:$PATH' >> ~/.profile
    source ~/.profile
    
    ## Update your ports
    sudo port -dv selfupdate
    
  8. Re-install your ports.
  9. Post nice comments.  🙂

UPDATE: 2013-10-23 – I really appreciate the feedback I’ve been getting on this page.  If the steps above don’t work perfectly for you, please check the comments below. 

UPDATE 2: 2013-10-23 – My apologies to everyone for the site slowness and instability earlier.  This was a new VM and I hadn’t optimized my Apache config.  I was caught a little off-guard by the huge increase in traffic.  🙂

UPDATE 3: 2013-10-24 – Thanks to all of the wonderful contributors to this thread, there are new, improved and simplified instructions. The current instructions have been tested in a brand new Mavericks VM, but should also work with systems that have previous MacPorts installs. If you have any problems, please leave me feedback and I’ll try to help.