Getting Octave to Just Goddamn Work Already on OS X 10.8 Mountain Lion

The So-Help-Me-God Edition

If you are in the fortunate position to be a lucky owner of a spiffy new Macbook, I salute you! In my humble opinion there could not be a finer breed of computer. Savor it, my friend!

However, if you are in the unfortunate position of needing to implement algorithms and plots in GNU Octave, I pity you. It is your fate to run through the gauntlet of Unix dependency hell that is getting open source software to work on a closed source operating system.

But I have good news! Hopefully, I have now exposed all the booby traps that Mountain Lion has set for you, and I've discovered the secret command-line incantations necessary to avoid them. Yes, much like Indiana Jones and the Last Crusade, I will now deftly disarm the traps so that you may pass freely into the chamber of the Holy Grail1. Choose wisely.


  1. First, install XQuartz. In the past this came installed on OS X, but as of Mountain Lion it is no longer included. So go fix that.
  2. You will also need the Xcode Command Line Tools if you don't already have them. Both Homebrew and XQuartz need this to work.
  3. Now you are ready to install Octave from Homebrew:2

    If you don't know what Homebrew is, then do me a favor and slap yourself a couple times. Install Homebrew now; thank me later.

Wow, Neil, that was easy! That's it, huh?
NO, YOU FOOL!

  1. Octave claims to have native drawing support using FLTK, but I haven't been able to get it working yet. We'll rely on gnuplot instead, which must be installed separately:
  2. Now edit your Octave startup file or create a new one:

    and add the line:
    (btw, to save and exit vim, type ':wq', or to exit without saving, type ':q')
  3. Now for the ultimate fix: reboot your machine! Yep, until you restart your Mac, Octave will be unable to launch XQuartz on its own, and you won't be able to plot anything.
  4. Once you're back in, open the terminal, fire up Octave, and plot a sombrero(). You're all set!

 


  1. The Holy Grail of Octave? Okay, not the greatest analogy.
  2. If you're having trouble with this step, see: Octave for OS X
Tagged , , , , . Bookmark the permalink.

23 Responses to Getting Octave to Just Goddamn Work Already on OS X 10.8 Mountain Lion

  1. Andrew says:

    Will this workflow still apply under Mavericks?

  2. ntraft says:

    Good question. :-P
    I'll let you know once I update, possibly today.

  3. Adjoa says:

    Thanks Neil--this worked perfectly and I didn't need to reboot my Mac either!

    I'm also curious about any Mavericks troubles.

  4. Gany says:

    Hey, thank you so much man.. I'm new to Macs, this helped install octave without breaking a sweat :)

  5. Andrew says:

    No mavericks test yet?

  6. Kate says:

    Well, I don't have it working on Mavericks, and a bit of searching shows I'm not the only one. Going to use ubuntu on virtual box until this is sorted :) .

  7. ntraft says:

    Update: I finally ugpraded to Mavericks and am happy to report that Octave works just fine. I also upgraded XQuartz from 2.7.4 to 2.7.5 and it worked with both versions.

    @Kate: Sorry to hear you're having trouble. What kinds of problems are you having exactly?

  8. Patrick says:

    Any thoughts on how to get this running without using Homebrew? I don't like what brew does to my /usr/local.

  9. ntraft says:

    @Patrick: Pretty sure you can tell brew to install wherever you want, e.g. /opt/local like Macports does. But if you still prefer Macports, check out the link I gave in the footnotes here. On that same page there are also instructions for installation via Macports.

  10. Cliff says:

    I have Octave working on Mavericks; however, Gnuplot still will not work. it repeatedly gives me the argument:
    gnuplot> set terminal aqua enhanced title "Figure 1" size 560 420 font "*,6"
    ^
    line 0: unknown or ambiguous terminal type; type just 'set terminal' for a list

    I am unable to get your x11 fix above to work (other than doing it every time I open up a new terminal).
    1. Do you have any idea how to fix this?
    2. Do you know how to just install Aquaterm?
    Thanks

  11. ntraft says:

    @Cliff:
    So it does work when you explicitly run export GNUTERM=x11 on the command line before starting Octave? In that case, your .profile must not be getting sourced. Sorry I didn't explain those so well. I actually didn't understand them when I wrote this.

    If you don't already have a .bash_profile, then you should create one with a single line:

    This will ensure that .profile always gets run.

    Alternatives:
    - Put the following line into your .octaverc:

    This might be the best option because then it will get set no matter what shell you're using.
    - Use zsh instead, and put the line into .zshrc, which always gets run.
    - As you said, you could also install aquaterm, but I think XQuartz is much superior and better supported.

  12. Shaima says:

    Thank you for the clear instructions and for the additional information about adding export GNUTERM=x11.

  13. Ignacio Sales says:

    Thanks so much for this.

    I just got a brand new Mac with Mavericks on it and was getting so frustrated with the painful install process... which was a breeze in Windows 7! :-S.

    Anyway where I was getting stuck was on the install of gnu plot, but once I used Homebrew to install everything went fine.

    Thanks again

    IS

  14. vvk says:

    The install of Octave on Mavericks worked fine as per the instruction above. I do have a strange issue with the Plot Function.

    The plot(x,y,'rx','MarkerSize',10) works fine when I am doing a command line. When I call this from a script file as a function, then I get an error of invalid Syntax.

  15. jackie says:

    Thanks for the article, especially for the ultimate fix- rebooting! I was stucked without rebooting...

  16. ellenjulia says:

    I'm trying to install octave on Mountain Lion and I'm getting hung up installing octave via these instructions as follows:
    ==> Installing octave dependency: suite-sparse
    ==> Downloading http://www.cise.ufl.edu/research/sparse/SuiteSparse/SuiteSparse-

    curl: (22) The requested URL returned error: 403
    Error: Failed to download resource "suite-sparse"
    Download failed: http://www.cise.ufl.edu/research/sparse/SuiteSparse/SuiteSparse-4.2.1.tar.gz

    Any thoughts? The internet has failed me so far.

  17. ntraft says:

    @ellenjulia:
    I just checked my installation... brew info suite-sparse shows it as installed. I think a 403 can happen if a file isn't given the right permissions on the server... so maybe it was a temporary issue on the SuiteSparse server?

    It seems fine now so maybe try again? (I was just able to download it from the link you provided)

    If not, then maybe their server is denying you for some other reason... you might try downloading it from another computer to diagnose the issue...

  18. Hans says:

    I'm running 10.8.5 and XQuartz won't install at all. It hangs up half way through the install. I've tried everything. Nothing works.

    What's more, I can't get any help anywhere. Not even Sourceforge will answer my emails about it. It seems support for X11 has simply been wiped off the face of the Earth as if it never existed.

    Please, somebody, ANYBODY, stop me before I buy a gun & shoot a big hole through this stinking Mac Mini !!!

  19. ntraft says:

    @Hans: Upgrade to Mavericks? ¯\_(ツ)_/¯

  20. Carl says:

    If you want to avoid the MacTeX dependency you can install Octave with brew as follows:

    brew install octave --without-docs

    source:
    http://stackoverflow.com/questions/23763885/error-while-installing-octave

  21. ZR says:

    When I'm brewing Octave, I get:
    Error: Unsupported special dependency :java

    I tried the following command:
    brew install octave --build-from-source --without-java

    Same results
    Error: Unsupported special dependency :java

    Trying to brew upgrade, have some issue with a local commit.. ugh

  22. ZR says:

    Never mind - brew install && upgrade was absolutely necessary. First had to reset the git repo in the Cellar before I could update. Upgrading everything led Brew to ask me if I wanted to update Java (via Cask?). That fixed everything

  23. Anon says:

    I did all this and I still got unknown terminal x11 errors. I had to add one final step:

    brew uninstall gnuplot;brew install gnuplot --with-x

    Now octave works with x11.

    Oh, I needed the slightly different setenv("GNUTERM", "X11") in the octaverc file, too.

Leave a Reply

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