Installing MacPorts on MacOS 10.14 Mojave

Update 10.15: If you are looking for instructions on how to install MacPorts on Catalina, try here.

Another year, another OS X update.  (Yes, I do copy a fair chunk of the text from previous year’s posts.)  I assume you are here because you downloaded the Mojave Beta/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 Mojave 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 Mojave. If you are attempting an upgrade from any previous version, your process may vary in unexpected ways.  If you did an upgrade install, 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 "Mojave"
  2. Connect to the internet
  3. Install Xcode 10 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 xcode-select --install
  7. When the pop-up launches, install the command line tools.
  8. cd ~/Desktop
  9. mkdir macports
  10. cd macports
  11. curl -O
  12. tar -xzvf MacPorts-2.5.3.tar.gz
  13. cd MacPorts-2.5.3
  14. ./configure
  15. make
  16. sudo make install
  17. echo export\ PATH=/opt/local/bin:/opt/local/sbin:\$PATH >> ~/.profile
  18. source ~/.profile
  19. sudo port -v selfupdate

There’s one extra step I find worth doing that isn’t strictly required for installing the MacPort installer tools.  I find it useful to install Java on my machine before I install any ports.  Otherwise you will be plagued with pop-up windows recommending you install Java while compiling ports like rsync.

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 rsync, wget, git, python27, which are my usual first validation tests.  Those packages, combined with their dependencies, result in around  75 installed packages; which does a pretty good job of verifying MacPorts is working.  🙂

Updated 2018/09/26 – Tightened up my sloppy use of a root privileged shell after barrykn called me out on it on reddit.  🙂

Updated 2018/10/02 – Fixed the smart-quote thing, so #17 should work now without needed to have the quotes tweaked. Crap! Smart quotes are back. Stupid theme updates…

24 Replies to “Installing MacPorts on MacOS 10.14 Mojave”

  1. The ‘uninstall’ link that you posted doesn’t work:

    # port -fp uninstall installed
    Error: Current platform “darwin 18” does not match expected platform “darwin 17”
    Error: If you upgraded your OS, please follow the migration instructions:
    OS platform mismatch
    while executing
    “mportinit ui_options global_options global_variations”
    Error: /opt/local/bin/port: Failed to initialize MacPorts, OS platform mismatch

    1. You are correct. The first part of those instructions, provided by the MacPorts project, do not work if you try to uninstall MacPorts after you upgrade to Mojave. The ‘sudo rm -rf’ command on that page will brute force you into an uninstalled state, which is why I’ve kept the link as part of the instructions.

    2. You can install right over the top of the older version & then issue the remove all packages. Once complete reinstall whatever.

      1. Yup, you can… But I always do my docs from the standpoint of a clean install to reduce the number of comments asking for help caused by some inconsistent crud left around. 🙂

  2. I got this error on line 18:
    $ echo ‘export PATH=/opt/local/bin:/opt/local/sbin:$PATH’ >> ~/.profile
    $ source ~/.profile
    -bash: ‘export: command not found

    1. I am rally sorry about that. It seems WordPress is converting the single quotes in that command into ‘smart quotes’. I’m trying to figure out how to fix that… Copy the command, replace the smart quotes with single quotes, and hit enter. You are also going to need to load ~/.profile into an editor and remove the broken line that was created by the echo with the bad quotes. Technically, you don’t need to remove the line, as it isn’t breaking anything; but you will get an error message every time you open a terminal window if you don’t remove the line, forever reminding you that I suck at WordPress formatting. 🙂

      1. Hi Chris,

        Could you explain a bit more in terms of how to get rid of this error message? I’m getting that line every time I start Terminal now.

        1. I don’t see your error message. If you had a screen shot it seems to have gotten lost. I’ll take a wild shot in the dark and say that WordPress’s stupid smart quotes on #17 bungled your .profile
          You will need to open .profile in a plaintext safe editor (I recommend atom ) and remove the quotes from the export path line at the bottom of your .profile

    2. open .profile file using this command: nano ~/.profile
      then, you will see the incorrect text, delete all texts
      then, add: export PATH=/opt/local/bin:/opt/local/sbin:$PATH
      then, save that file

  3. Thank you, it was very helpful and without any glitch in my specific case: Mojave OS update from “El Capitan”.

  4. well, I was also running into the issue of a platform mismatch. doing the brute force install, and then the instructions above definitely worked out for me. Also, installed Java (just to be safe). One note here, I am a totally blind user, so I had to make sure that the smart quote issue didn’t crop up (thank god for textedit).. Now, all I need to do is upgrade the compiler, python, ruby, perl and all of that. 🙂

  5. My €.02:

    Step 6: “sudo xcode-select –install”: this should be –install (i.e., two minuses; perhaps this is WordPress “helpfully” collapsing them into a single en-dash?)

    Thank you!!

    1. I bloody hate some of the things that WordPress’s style does to my more technical posts. Fiddling with double-hyphens, stupid smart quotes… And every time I fix the styles I do something dumb like update my theme and have to start all over. murgle!

  6. Made sense. I’ve worked with Unix, Linux, and C++ programing enough to see the other instructions were trying to get at when i looked for installation instructions but in the end they made some assumption or missed some step. Your clear description and complete list of steps worked. Thanks.

  7. Followed ur instruction to the “T”….didn’t work for me.
    i.e. brew install vlc
    -bash: brew: command not found

Leave a Reply to gensym Cancel reply

Your email address will not be published.

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