title: Error: package or namespace load failed for ‘rjags’
body: <p>I have a M1 Macbook Pro running OS Big Sur and just tried to install <code>rjags</code> and <code>JAGS</code>. I downloaded JAGS from <a href="https://sourceforge.net/projects/mcmc-jags/" rel="nofollow noreferrer">https://sourceforge.net/projects/mcmc-jags/</a> without a problem, and ran <code>install_packages(&quot;rjags&quot;)</code>, but when I run <code>library(rjags)</code> I get this error:</p>
  <pre><code>Loading required package: coda
  Error: package or namespace load failed for ‘rjags’:
   .onLoad failed in loadNamespace() for 'rjags', details:
    call: dyn.load(file, DLLpath = DLLpath, ...)
    error: unable to load shared object '/Users/afredston/Library/Caches/org.R-project.R/R/renv/cache/v5/R-4.1/aarch64-apple-darwin20/rjags/4-12/e8a71b3a154c8e68c152b4cfbebfdd97/rjags/libs/rjags.so':
    dlopen(/Users/afredston/Library/Caches/org.R-project.R/R/renv/cache/v5/R-4.1/aarch64-apple-darwin20/rjags/4-12/e8a71b3a154c8e68c152b4cfbebfdd97/rjags/libs/rjags.so, 10): Library not loaded: /opt/R/arm64/lib/libjags.4.dylib
    Referenced from: /Users/afredston/Library/Caches/org.R-project.R/R/renv/cache/v5/R-4.1/aarch64-apple-darwin20/rjags/4-12/e8a71b3a154c8e68c152b4cfbebfdd97/rjags/libs/rjags.so
    Reason: image not found
  </code></pre>
  <p>I understand this means that R cannot &quot;find&quot; the installation of JAGS. I am using <code>renv</code> for this project, but even if I deactivate it and re-run <code>install_packages(&quot;rjags&quot;)</code> and <code>library(rjags)</code> I get the error (just with different file paths):</p>
  <pre><code>Loading required package: coda
  Error: package or namespace load failed for ‘rjags’:
   .onLoad failed in loadNamespace() for 'rjags', details:
    call: dyn.load(file, DLLpath = DLLpath, ...)
    error: unable to load shared object '/Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/library/rjags/libs/rjags.so':
    dlopen(/Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/library/rjags/libs/rjags.so, 10): Library not loaded: /opt/R/arm64/lib/libjags.4.dylib
    Referenced from: /Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/library/rjags/libs/rjags.so
    Reason: image not found
  </code></pre>
  <p>I'm a stats person without much back-end computer expertise so I'd appreciate help resolving this!</p>