Running R2WinBUGS on a Mac Running OSX

I have long used JAGS to do all of my Bayesian work on my mac. Early on, I tried to figure out how to install WinBUGS and OpenBUGS and their accompanying R libraries on my mac, but, to no avail. I just had too hard of a time getting them running and gave up.

But, it would seem that some things have changed with Wine lately, and it is now possible to not only get WinBUGS itself running nicely on a mac, but to also get R2WinBUGS to run as well. Or at least, so I have discovered after an absolutely heroic (if I do say so myself) effort to get it all running (this was to help out some students I’m teaching who wanted to be able to do the same exercises as their windows colleagues). So, I present the steps that I’ve worked out. I do not promise this will work for everyone – and in fact, if it fails at some point, I want to know about it so that perhaps we can fix it so that more people can get WinBUGS up and running.

Or just run JAGS (step 1} install the latest version, step 2} install rjags in R. Modify your code slightly. Run it. Be happy.)

So, this tutorial works to get the whole WinBUGS shebang running. Note that it hinges on installing the latest development version of Wine, not the stable version (at least as of 1/17/12). If you have previously installed wine using macports, good on you. Now uninstall it with “sudo port uninstall wine”. Otherwise, you will not be able to do this.

Away we go!

1) Have the free version of XCode Installed from You may have to sign up for an apple developer account. Whee! You’re a developer now!

2) Have X11 Installed from your system install disc.

3) Install and install from the package installer. See also here for more information. Afterwards, open the terminal and type

echo export PATH=/opt/local/bin:/opt/local/sbin:$PATH$'n'export MANPATH=/opt/local/man:$MANPATH | sudo tee -a /etc/profile

You will be asked for your password. Don’t worry that it doesn’t display anything as you type. Press enter when you’ve finished typing your password.

4) Open your terminal and type

sudo port install wine-devel

5) Go have a cup of coffe, check facebook, or whatever you do while the install chugs away.

6) Download WinBUGS 1.4.x from here. Also download the immortality key and the patch.

7) Open your terminal, and type

cd Downloads
wine WinBUGS14.exe

Note, if you have changed your download directory, you will need to type in the path to the directory where you download files now (e.g., Desktop).

8 ) Follow the instructions to install WinBUGS into c:Program Files.

9) Run WinBUGS via the terminal as follows:

wine ~/.wine/drive_c/Program Files/WinBUGS14/WinBUGS14

10) After first running WinBUGS, install the immortality key. Close WinBUGS. Open it again as above and install the patch. Close it. Open it again and WinBUGS away!

11) To now use R2WinBugs fire up R and install the R2WinBUGS library.

12) R2WinBugs should now work normally with one exception. When you use the bugs function, you will need to supply the following additional argument:'/Users/YOURUSERNAME/.wine/drive_c/Program Files/WinBUGS14'

filling in your username where indicated. If you don’t know it, in the terminal type

ls /Users

No, ~ will not work for those of you used to it. Don’t ask me why.

16 thoughts on “Running R2WinBUGS on a Mac Running OSX

  1. Thanks very much for these great tips. I noticed a few typos:

    In 8) typo: wine should be WinBUGS.

    In 9)

    wine ~/.wine/drive_c/Program Files/WinBUGS14

    should be:
    wine ~/.wine/drive_c/Program Files/WinBUGS14/WinBUGS14

    In 10) typo: wine should be WinBUGS.

    In 12) you may also need to include in the bugs() call the locations of wine and winepath:

    Also Wineskin Winery provides a faster way of getting WinBUGS up and running on a Mac. See this blog here:


  2. Thanks for the fixes. #12 is not needed if you have properly installed macports. I also tried wineskin, but, had problems with the wine of macports and the wine of wineskin and/or wine bottler not playing nicely together, so, that’s why I recommend just doing it all via the terminal rather than an app.

  3. Thanks for this. Did you run into an error like this:

    err:ole:CoGetClassObject class {0003000a-0000-0000-c000-000000000046} not registered
    err:ole:CoGetClassObject class {0003000a-0000-0000-c000-000000000046} not registered
    err:ole:CoGetClassObject no class object {0003000a-0000-0000-c000-000000000046} could be created for context 0×3

    Based on a Google search this is a common roadblock for running WinBUGS in OSX. If you didn’t run into this issue, could you share the versions of OSX, macports, wine, etc. you are using?

    Thanks again!

  4. Pingback: Running OpenBUGS on a Mac Running OSX « i'm a chordata! urochordata!

  5. Hey, thanks for your tutorial. I followed it but I got the error message as follows:

    err:ole:CoGetClassObject class {0003000a-0000-0000-c000-000000000046} not registered
    err:ole:CoGetClassObject class {0003000a-0000-0000-c000-000000000046} not registered
    err:ole:CoGetClassObject no class object {0003000a-0000-0000-c000-000000000046} could be created for context 0×3

    I also tried to do wineprefix in terminal

    WINEPREFIX=”/Library/Application Support/Wine/prefixes/WinBUGS” wine ~/Downloads/WinBUGS14/WinBUGS14.exe

    It told me that

    wine: chdir to /Library/Application Support/Wine/prefixes/WinBUGS
    : No such file or directory

    However, I CAN see the directory in terminal… No clue what’s going on.

    Could you please help me out? Any help is appreciated! I’m running on mountain lion BTW.

  6. I admit, I have not done this on Mountain Lion, so your first set of error messages may be OS specific. The wine prefix stuff is odd. Are you using curly quotes? Honestly, that can sometimes alter things (weird, I know) – although I doubt it here. What about adding a trailing / to WinBUGS?

  7. Hey, thanks for your reply. I tried your tricks. It doesn’t solve the problem. The thing is that WinBUGS does pop out, but is not passed with data. I have no clue what’s going on.

  8. Hi all — I’m a bit new to the bayesian game and also now installing WinBUGS through WINE. I’ve been having the same error/warning as CC, though WinBUGS does seem to run….

    I realize the thread is a bit old, but I was just wondering if anyone had unearthed any new fixes since?


  9. I am really running out of ideas…
    I tried the suggested procedure (uninstalled the latest stable Wine version and installed the development) but still get an error message

    wine: could not run L”Z:\\Users\\….\\Downloads\\WInBUGS14.exe”: 16-bit/DOS support missing

    which supposedly is not solvable…?
    I have started with installing OpenBUGS322, which I succeeded after some tweeks, it opens and runs but it gives an error while computing
    Error in matrix(, n.sims, n.parameters) :
    invalid ‘nrow’ value (too large or NA)
    supposed to be related specifically to OpenBUGS322 but cannot get OpenBUGS321 anywhere.

    WinBUGS I am not even able to run (also tried WineBottler – but than it keeps installing it not opening — that may be my fault… ?)

    I would incredibly appreciate any advice.

    I am running OS X 10.5.8


  10. Just a little addition:
    I wasn’t sure whether just WinBUGS14.exe or was appropriate to download. I tried both.

    If I download the WinBUGS14.exe and try to run it with wine
    I get
    WinBUGS14.exe”: 16-bit/DOS support missing

    If I download the zip folder, extract it and try to run WinBUGS14.exe with wine
    It does not install but opens the WinBUGS directly.
    I have decoded the key and the patch, however when trying to run WinBUGS from R it doesn’t work. I get error messages in R and WinBUGS.

    CoGetClassObject no class object {0003000a-0000-0000-c000-000000000046} could be created for context 0×3

    Log from WinBUGs
    Educational version cannot run this model
    History command Bugs history cannot be executed (is greyed out)

    (I have downloaded and installed XQuartz, Xcode, MacPorts, Wine… (working on X OS 10.5.8)

  11. Just done it, get an error message but the results seems ok (Running on mountain lion and 64-bit R and Winbugs)

    However, think I’ll just install Jags and see if that runs smoother.

    Thanks for the walkthrough though :)

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>