Menu

#11 Unable to install RJAGS, R 4.1.1 on Mac OS Big Sur, 2018 Mac Pro, Intel I9.

v1.0_(example)
open
nobody
None
1
2022-04-27
2022-04-22
Anonymous
No

Unfortunately, I am having an issue with installing RJAGS on Mac OS Big Sur, 2018 Mac Pro, Intel I9.
Running R 4.1.1. I have installed JAGS and I am able to run that program independently.

I also worked through the devtools include option mentioned above but still no luck. Any thoughts?

Approach 1

>install.packages("rjags")
* installing *source* package rjags ...
** package rjags successfully unpacked and MD5 sums checked
** using staged installation
checking for pkg-config... /usr/local/bin/pkg-config
configure: Setting compile and link flags according to pkg-config
configure: Compile flags are -I/usr/local/include/JAGS
configure: Link flags are -L/usr/local/lib -ljags
checking for gcc... /usr/local/bin/gcc-11
checking whether we are using the GNU C compiler... no
checking whether /usr/local/bin/gcc-11 accepts -g... no
checking for /usr/local/bin/gcc-11 option to accept ISO C89... unsupported
checking for jags_version in -ljags... yes
checking version of JAGS library... OK
configure: creating ./config.status
config.status: creating src/Makevars
configure: creating ./config.status
config.status: creating src/Makevars
config.status: creating R/unix/zzz.R
** libs
/usr/local/bin/gcc-11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/usr/local/include/JAGS   -I/usr/local/include   -fPIC  -Wall -g -O2  -c init.c -o init.o
/usr/local/bin/g++-11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/usr/local/include/JAGS   -I/usr/local/include   -fPIC  -Wall -g -O2  -c jags.cc -o jags.o
/usr/local/bin/g++-11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/usr/local/include/JAGS   -I/usr/local/include   -fPIC  -Wall -g -O2  -c parallel.cc -o parallel.o
/usr/local/bin/g++-11 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o rjags.so init.o jags.o parallel.o -L/usr/local/lib -ljags -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
installing to /Library/Frameworks/R.framework/Versions/4.1/Resources/library/00LOCK-rjags/00new/rjags/libs
** R
** data
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
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/Resources/library/00LOCK-rjags/00new/rjags/libs/rjags.so':
  dlopen(/Library/Frameworks/R.framework/Versions/4.1/Resources/library/00LOCK-rjags/00new/rjags/libs/rjags.so, 10): Symbol not found: __ZN4jags11SimpleRangeC1ERKSt6vectorIiSaIiEES5_
  Referenced from: /Library/Frameworks/R.framework/Versions/4.1/Resources/library/00LOCK-rjags/00new/rjags/libs/rjags.so
  Expected in: flat namespace
 in /Library/Frameworks/R.framework/Versions/4.1/Resources/library/00LOCK-rjags/00new/rjags/libs/rjags.so
Error: loading failed
Execution halted
ERROR: loading failed
* removing /Library/Frameworks/R.framework/Versions/4.1/Resources/library/rjags

The downloaded source packages are in
    /private/var/folders/_3/8v09s_c91fs5myl646c2_ts80000gp/T/Rtmp0930vW/downloaded_packages
Warning message:
In install.packages("rjags") :
  installation of package rjags had non-zero exit status

Approach 2: Devtools

>devtools::install_url("http://sourceforge.net/projects/mcmc-jags/files/rjags/4/rjags_4-4.tar.gz",
                      args="--configure-args='--with-jags-include=/usr/local/include/JAGS 
                                                                 --with-jags-lib=/usr/local/opt/jags/lib'
                            ")

Downloading package from url: http://sourceforge.net/projects/mcmc-jags/files/rjags/4/rjags_4-4.tar.gz
  checking for file /private/var/folders/_3/8v09s_c91fs5myl646c2_ts80000gp/T/Rtmpark1rv/remotes3785557112a/rjags/DESCRIPTION ...
  preparing rjags:
  checking DESCRIPTION meta-information ...
  cleaning src
  running cleanup
  checking for LF line-endings in source and make files and shell scripts
  checking for empty or unneeded directories
  looking to see if a data/datalist file should be added
  building rjags_4-4.tar.gz

* installing *source* package rjags ...
** using staged installation
checking for pkg-config... /usr/local/bin/pkg-config
configure: Setting compile and link flags according to pkg-config
configure: Compile flags are -I/usr/local/include/JAGS
configure: Link flags are -L/usr/local/lib -ljags
checking for gcc... /usr/local/bin/gcc-11
checking whether we are using the GNU C compiler... no
checking whether /usr/local/bin/gcc-11 accepts -g... no
checking for /usr/local/bin/gcc-11 option to accept ISO C89... unsupported
checking for jags_version in -ljags... yes
checking version of JAGS library... OK
configure: creating ./config.status
config.status: creating src/Makevars
configure: creating ./config.status
config.status: creating src/Makevars
config.status: creating R/unix/zzz.R
** libs
/usr/local/bin/g++-11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/usr/local/include/JAGS   -I/usr/local/include   -fPIC  -Wall -g -O2  -c jags.cc -o jags.o
jags.cc: In function 'jags::SimpleRange makeRange(SEXP, SEXP)':
jags.cc:213:29: warning: catching polymorphic type 'class std::logic_error' by value [-Wcatch-value=]
  213 |     catch (std::logic_error except) {
      |                             ^~~~~~
/usr/local/bin/g++-11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/usr/local/include/JAGS   -I/usr/local/include   -fPIC  -Wall -g -O2  -c parallel.cc -o parallel.o
/usr/local/bin/g++-11 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o rjags.so jags.o parallel.o -L/usr/local/lib -ljags -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
installing to /Library/Frameworks/R.framework/Versions/4.1/Resources/library/00LOCK-rjags/00new/rjags/libs
** R
** data
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
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/Resources/library/00LOCK-rjags/00new/rjags/libs/rjags.so':
  dlopen(/Library/Frameworks/R.framework/Versions/4.1/Resources/library/00LOCK-rjags/00new/rjags/libs/rjags.so, 10): Symbol not found: __ZN4jags11SimpleRangeC1ERKSt6vectorIiSaIiEES5_
  Referenced from: /Library/Frameworks/R.framework/Versions/4.1/Resources/library/00LOCK-rjags/00new/rjags/libs/rjags.so
  Expected in: flat namespace
 in /Library/Frameworks/R.framework/Versions/4.1/Resources/library/00LOCK-rjags/00new/rjags/libs/rjags.so
Error: loading failed
Execution halted
ERROR: loading failed
* removing /Library/Frameworks/R.framework/Versions/4.1/Resources/library/rjags
Warning messages:
1: In i.p(...) :
  installation of package /var/folders/_3/8v09s_c91fs5myl646c2_ts80000gp/T//Rtmpark1rv/file3781530638c/rjags_4-4.tar.gz had non-zero exit status
2: 1 components of `...` were not used.

We detected these problematic arguments:
* `args`

Did you misspecify an argument? 

Discussion

  • Martyn Plummer

    Martyn Plummer - 2022-04-22

    The compiler is complaining about about the absence of a function in the JAGS library. When the name is demangled, the missing function is:

    jags::SimpleRange::SimpleRange(std::vector<int> const&, std::vector<int> const&);
    

    This function is indeed in the JAGS library that comes with JAGS 4.3.1. This raises two possibilities:
    1. You have installed an earlier, incompatible version of JAGS, or
    2. You are using an incompatible compiler to compile rjags

    Which version of JAGS did you install?

    Remember that rjags binary packages for MacOS are available from CRAN. You can try

    install.packages("rjags",  type="binary")
    

    Finally, don't use the second approach for rjags because the source packages on SourceForge are not up to date (version 4-4 vs 4-13 on CRAN).

     

    Last edit: Martyn Plummer 2022-04-22
  • Anonymous

    Anonymous - 2022-04-26

    Thanks Martyn for the very quick response. I really appreciate this help! I installed JAGS from https://sourceforge.net/projects/mcmc-jags/files/JAGS/4.x/Mac%20OS%20X/ , which only has the 4.3.0 option. Should I be finding the 4.3.1 version there? Thanks!

     
    • Martyn Plummer

      Martyn Plummer - 2022-04-26

      There's no difference between 4.3.0 and 4.3.1 on Mac OS. This patch release is for Windows only and is triggered by the change in the compiler used to compile R on Windows.

       
  • Anonymous

    Anonymous - 2022-04-26

    Thanks Martyn.

    The 4.3.0 install did go through properly. I am able to run jags independently on the terminal like below. But if I try to install RJAGS like above with "install.packages", I get the compiler issue.

    jags
    Welcome to JAGS 4.3.0 on Tue Apr 26 15:20:58 2022
    JAGS is free software and comes with ABSOLUTELY NO WARRANTY
    Loading module: basemod: ok
    Loading module: bugs: ok
    .

     
    • Martyn Plummer

      Martyn Plummer - 2022-04-27

      My guess is that you are using incompatible compilers for rjags and JAGS. Calling @mdenwood . Sorry to keep doing this to you Matt but I'm not really sure what goes on on Mac OS.

       
  • Matt Denwood

    Matt Denwood - 2022-04-27

    I think Martyn's guess is spot on: your configure output shows "/usr/local/bin/gcc-11" but the standard toolchain on macOS is clang. So I guess you have at some point installed gcc compilers (e.g. via homebrew?) which are now being picked up ahead of Apple's clang compilers.

    To quote https://mac.r-project.org/tools/:

    "NOTE: In order to retain compatibility with native R we recommend using above tools. Although it is possible to compile R using tools from other package managers such as Homebrew, MacPorts or Fink, such binaries are by definition incompatible with macOS native libraries and applications. If you choose one of those package managers, make sure you compile everything using those tools including R and all packages and libraries you intend to use."

    So you need to ensure that R, JAGS and rjags are all compiled using the same tools. This means that you either need to compile R and JAGS yourself using gcc-11, or you need to ensure that clang is picked up (and used) before GCC.

    What is your path currently set to? i.e. run echo $PATH in a terminal and show us the output.

    Matt

     
  • Anonymous

    Anonymous - 2022-04-27

    Thank you very much Martyn and Matt!

    You both are absolutely right. I am indeed using gcc-11 with RCPP and related applications.
    OK if I don't want to change to clang, I will need to find a way to compile JAGS with gcc-11 then. Thanks !

     
  • Matt Denwood

    Matt Denwood - 2022-04-27

    OK, glad we found the issue :)

    If you are already building R yourself (which it sounds like you are?) then building JAGS should not be so difficult. Something like the following should do:

    VER=4.3.1
    curl -OL https://sourceforge.net/projects/mcmc-jags/files/JAGS/4.x/Source/JAGS-${VER}.tar.gz
    tar xf JAGS-${VER}.tar.gz
    cd JAGS-${VER}
    ./configure --prefix=/usr/local \
        --with-blas='-framework Accelerate' --with-lapack='-framework Accelerate' \
        CFLAGS='-O2 -mmacosx-version-min=10.13' CXXFLAGS='-O2 -mmacosx-version-min=10.13' \
        F77="/usr/local/bin/gfortran"
    make -j 8
    sudo make install
    

    Or something like that :)

    Then installing rjags should work as you were doing previously.

     

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.