Installing brms on macbook pro with M1pro silicon

Here’s what I get when I try to install brms in RStudio on the expensive and infuriating machine. I have installed gfortran in the correct place in “opt.” I can run
rstan successfully with this command:
example(stan_model, package=“rstan”,run.dontrun=TRUE)

When I do


The result is:

installing the source package ‘brms’

trying URL ‘
Content type ‘application/x-gzip’ length 4957623 bytes (4.7 MB)

downloaded 4.7 MB

  • installing source package ‘brms’ …
    ** package ‘brms’ successfully unpacked and MD5 sums checked
    ** using staged installation
    ** R
    Warning: namespace ‘brms’ is not available and has been replaced
    by .GlobalEnv when processing object ‘brmsfit_example1’
    Warning: namespace ‘diffobj’ is not available and has been replaced
    by .GlobalEnv when processing object ‘brmsfit_example1’
    ** data
    *** moving datasets to lazyload DB
    ** inst
    ** byte-compile and prepare package for lazy loading
    Error in loadNamespace(j ← i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
    there is no package called ‘igraph’
    Calls: … loadNamespace → withRestarts → withOneRestart → doWithOneRestart
    Execution halted
    ERROR: lazy loading failed for package ‘brms’
  • removing ‘/Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/library/brms’
    Warning in install.packages :
    installation of package ‘brms’ had non-zero exit status

The downloaded source packages are in

Any help would be appreciated.
Be well.
Ted W. Simon

@andrewheiss, you might have some guidance on this.

FWIW, I have recently seen the same error for a package that depends on brms on Github CI, including on Windows and Linux as well as Mac, so I don’t think this is an M1 issue. I haven’t had time to dig or troubleshoot yet (because I need brms work I haven’t dared to mess with anything locally). See here:

I bought a Macbook Pro M1pro last week. I installed brms successfully. It will run with igraph v. 1.2.8 which doesn’t need compiling. But my toolchain will not compile igraph 1.2.9.

I set up a completely fresh installation of R 4.1.2 silicon and RStudio 2021.09.1 Build 372. I used Coudert’s fortran compiler at François-Xavier Coudert | Software development. I used the “experimental” v11 gfortran for Apple Silicon, Xcode 13.1, Xquartz 2.8.1. Everything works fine. Make sure you get the fortran install in ~/opt.

Use cmd-shift-period to see the hidden files in finder and change permissions so you can put things where they need to be.

The M1pro is amazingly fast – about 5-10x faster than M1 air.

Good luck!!

1 Like

I’ve been using brms, igraph, etc. without issue on my M1 - this guide here was indispensable for getting the toolchain set up correctly with all the right Makevars flags (plus it has instructions for using a faster BLAS library): Transitioning from x86 to arm64 on macOS - experiences of an R user

1 Like