R with Conda Forge
Conda is designed to work standalone. Letting it provide everything (including R and rjags) works fine. That is, try:
## create R 4.3 environment with rjags installed
mamba create -n r43_jags -c conda-forge r-base=4.3 r-rjags
and use the R in that environment. Note that jags need not be specified, only the r-rjags. In fact, it's best to let Conda/Mamba figure out the dependencies, rather than overspecifying things. The fact that Conda Forge has a r-rjags package means it knows how to correctly configure jags.
Generally, if using Conda for R, avoid using install.packages() and stick to the Conda Forge channel. There are some additional tips for Conda + R here:
Example in Docker
Note: Docker is only used here to demonstrate a minimal environment. I am not suggesting to use Docker, but rather just demonstrate how simple it is to get rjags running, and how this requires absolutely no sudo or compilation.
$ docker run --rm -it condaforge/mambaforge:latest
## docker shell
(base) $ mamba create -yn foo r-base=4.3 r-rjags
(base) $ conda activate foo
(foo) $ R
R version 4.3.1 (2023-06-16) -- "Beagle Scouts"
Copyright (C) 2023 The R Foundation for Statistical Computing
Platform: x86_64-conda-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(rjags)
Loading required package: coda
Linked to JAGS 4.3.0
Loaded modules: basemod,bugs
>