How to run JAGS in R on Apple Silicon
Since upgrading to an Apple Silicon machine, which uses Apple's new M1 chip, I've had no problems using R. However, I recently ran into my first issue when trying to run a package that requires JAGS. While I was able to install JAGS via Homebrew, R couldn't seem to find my JAGS installation.
Here's what I did to get JAGS working on a M1 Mac running MacOS 11.5 with R version 4.1:
Install the Intel version of R (Intel/x86-64) from CRAN. When I was setting up my M1 Mac, I had installed the Arm64 version, which is designed for the new M1 Macs. The downside with using the Intel version is that R might run a little slower compared to the Arm64 version, but I didn't notice much of a difference
Install JAGS using the official DMG file
Open RStudio and confirm you're running the Intel version using the
versioncommand. The architechture (called 'arch' when you call this function) should be "x86_64" if you're running the intel version of R.
Now JAGS should be working in R.
If you would like to quickly switch between R versions, I would recommend installing RSwitch, which is a very handy utility that lives in your menu bar.
In the image above, you can see that I have both Intel and M1 versions of R 4.1 installed, and I currently have the Intel version running.