WinBUGS on Ubuntu and R2WinBUGS with Wine

July 27, 2010

The following is a how-to for setting up WinBUGS on the latest version of Ubuntu 10.04 LTS Lucid Lynx.

1. Install wine-1.0 not wine-1.2 (wine-1.2 will seg fault!)
sudo apt-get install wine-1.0

2. Download WinBUGS from here.

3. Navigate to the directory where you downloaded WinBUGS, I’ll assume it was /home/user/Downloads, and run the following:
wine WinBUGS14.exe

4. Launch WinBUGS
wine ~/.wine/drive_c/Program Files/WinBUGS14/WinBUGS14.exe

5. Patch WinBUGS with the following patch – available here. Apply that patch as described on the WinBUGS website. Then close WinBUGS and launch it again as previously described.

6. Add the immortality key – available here. Apply it the same way you did the patch!

7. Launch R and install R2WinBUGS

8. Load R2WinBUGS and run the Gelman example to check that it worked
model.file <- system.file(package="R2WinBUGS","model",
J <- nrow(schools)
y <- schools$estimate
sigma.y <- schools$sd
data <- list ("J", "y", "sigma.y")
inits <- function(){
list(theta=rnorm(J, 0, 100), mu.theta=rnorm(1, 0, 100),
sigma.theta=runif(1, 0, 100))
parameters <- c("theta", "mu.theta", "sigma.theta")
schools.sim <- bugs(data, inits, parameters, model.file, n.chains=3, n.iter=5000)

You will get a couple of messages from Wine, but I believe you can ignore these. I have not thoroughly tested this but I can corroborate that it gives similar estimates to R2WinBUGS from Windows (see below gnome-terminal vs. Windows XP in VirtualBox). I still recommend JAGS but if you need to use WinBUGS here is how.

Also this should work on any Linux distribution or Mac OS X provided that you can get Wine 1.0 as the latest Wine versions do not work with WinBUGS. Let me know if you have troubles.


9. Add a desktop launcher (OPTIONAL)
Right Click gnome-panel
Click 'Add to Panel ...'
Click 'Custom Application Launcher'

Add the following to the Name field

Add the following to the Command field (do include the quotes!)
wine '/home/USER/.wine/drive_c/Program Files/WinBUGS14/WinBUGS14.exe'

Finally, if you want to add the WinBUGS icon, click here. Right click the image and select:
Save image as ...

Save it to /home/user/Downloads/ and then add it by clicking the Wine icon, navigating to the directory where you downloaded it and finally selecting the icon. Then close the Custom Application Launcher dialog box by clicking Close.


  1. Hello, Thanks for this blog entry, it is just what I need. I am wondering if you are able to get those links in WinBuGS to work. I can’t see any of the help topic because all the links are just static, nothing happens when clicking them. If there is a choice I would prefer not to use wine. The program seems to be terribly broken.

    • Unfortunately no. The help menu seems to be pretty broken here. As you could tell from that screenshot, if I run *BUGS I will run it in Windows XP via a virtual machine, like VirtualBox. However, I prefer to run JAGS when possible. Also once BRUGS gets updated, I believe that OpenBUGS will be a viable option as it already available for Linux.

      • Hi,

        I reinstalled WinBUGS again (after deleting the .wine folder) and now the help manual is working, but it may take a few more clicks than usual to open up the hyperlink(Just keep clicking, there may be some kind of mouse configurations in wine that I haven’t set..)

        OpenBUGS is workable in Linux according to their website, but not with R because the R package BRugs ( kind of like R2WinBUGS, I guess) is only available for Windows. Unless there is a very recent change on the status of BRugs it would be Wine again if you want to use OpenBuGs with R in Linux. This is very frustrating. Are these people working for MicroSoft or what? đŸ˜¦

        I never use JAGS before. Does it have all the basic functionalities of BUGS so that I can just use JAGS and forget about BUGS?

  2. Yeah JAGS has most of the basic functionalities of BUGS and is native to Linux, Mac, and Windows. Martyn Plummer has developed JAGS with the purpose of it being multi-platform.

    BRugs should be updated soon based on the OpenBUGS website.

  3. There are a couple of solutions for getting WinBUGS to run successfully in newer version of WINE, which both seem to work OK.

    Add missing registry key:

    Install Native DCOM:

    This was good news for me since WINE 1.0 won’t build on my system due to library API changes.

    Unfortunately, I haven’t yet been able to get R2WinBUGS working with either one. It starts WinBUGS just fine, but then the program just sits there doing nothing. The WINE bug indicates that 1.1.12 should work without modification, so I suppose I can give that a shot.

    • I finally got the Gelman example working by creating a C:\temp\Rtmp directory in WINE and adding some parameters to the bugs() call:

      schools.sim <- bugs(data, inits, parameters, model.file, n.chains=3, n.iter=5000, working.directory="~/.wine/drive_c/temp/Rtmp/", clearWD=TRUE)

      The clearWD=TRUE is optional but causes bugs() to clean up after itself (so long as the codaPkg parameter is FALSE, which is the default).

      This was done using WINE 1.3.0, and applying both the missing registry key patch and installing the Native DCOM library as explained in the links from my previous comment. The native DCOM might not be necessary, although it seemed to fix some graphical glitches in WinBUGS, most notably the logo on the Licence page displayed at startup.

      The default working directory behavior of bugs() is to create an R temporary directory in /tmp/, then find whatever WINE drive letter is mapped to / and point WinBUGS to the temporary directory through that. The default in WINE is that Z maps to /, so bugs() was executing "WinBUGS14.exe /par Z:\tmp\RtmpSkjfd\script.txt" which I could not seem to get to work correctly. It was broken at first because I didn't have a WINE drive letter mapped to /, but even after fixing that it couldn't seem to find anything on Z. Changing to a manually specified temp directory on C seemed to sidestep whatever problem it was having.

      • Glad to hear this worked out for you.

  4. Thanks so much for this post. I just spent two hours trying to get WinBUGS to work on 11.04, and tried working around the wine issue. Re-installed wine-1.0 from Synaptic, and hey presto!

    Many thanks.

  5. […] R. (R 2.14.2) 2. Install wine.  (wine-1.4) 3. Install WinBUGS via wine and setup R2WinBugs. That guide was written for Ubuntu 10.04. Some modifications for Ubuntu […]

  6. With Ubuntu 12.04 the steps are the same except for: (1) wine-1.4 works great and (2) you have to use the working.directory option as mentioned by zcronix. Further details on my blog:


  7. I cannot install wine on my ubuntu. The error “Package dependencies cannot be resolved” always shows up

    • What version of ubuntu?

  8. not working in ubuntu 13.10

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: