Menu

Problem with rjags installation

Help
2021-09-30
2023-04-25
  • Kilian Knauth

    Kilian Knauth - 2021-09-30

    Hello,
    Unfortunately I got an error while I tried to load the rjags package. I installed JAGS 4.2.0 and downloaded rjags 4-4 frome here: https://sourceforge.net/projects/mcmc-jags/files/rjags/4/

    I tried the following: install.packages("rjags") which is giving me:

    Installing package into ‘~/R/win-library/4.0’
    (as ‘lib’ is unspecified)
    versuche URL 'https://cran.rstudio.com/bin/windows/contrib/4.0/rjags_4-11.zip'
    Content type 'application/zip' length 802917 bytes (784 KB)
    downloaded 784 KB
    package ‘rjags’ successfully unpacked and MD5 sums checked
    The downloaded binary packages are in
    ~\Local\Temp\RtmpSuj5cX\downloaded_packages

    Next I´ve tried to call "library(rjags)" which is giving me this error:

    Fehler: package or namespace load failed for ‘rjags’:
    .onLoad in loadNamespace() für 'rjags' fehlgeschlagen, Details:
    Aufruf: fun(libname, pkgname)
    Fehler: Failed to locate any version of JAGS version 4

    The rjags package is just an interface to the JAGS library
    Make sure you have installed JAGS-4.x.y.exe (for any x >=0, y>=0) from
    http://www.sourceforge.net/projects/mcmc-jags/files
    Zusätzlich: Warnmeldung:
    Paket ‘rjags’ wurde unter R Version 4.0.5 erstellt

    I am a little cueless how to proceed.
    Best regards!
    Kilian

     
  • Michael  Seo

    Michael Seo - 2021-09-30

    Yes, I got this problem as well when I updated rjags version from 4-10 to 4-11.

    Quick fix was to set the JAGS_HOME to where JAGS was installed by something like...
    Sys.setenv(JAGS_HOME=“C:\programs\JAGS\JAGS-4.0.0”)

    Well... I just reverted back to 4-10 (had to reinstall rtools) and it works again without setting JAGS_HOME.

    Please fix this issue...

    Best,
    Mike

     

    Last edit: Michael Seo 2021-09-30
  • Kilian Knauth

    Kilian Knauth - 2021-10-01

    Ah thank you so much!
    The quick fix did it.

    Best,
    Kilian

     
  • Jean Carlos Velez Rodriguez

    I installed JAGS 4.3.0 and rjags 4-4,. When trying to call library(rjags) I get the following output:

    library(rjags)
    Error: package or namespace load failed for ‘rjags’:
    .onLoad failed in loadNamespace() for 'rjags', details:
    call: fun(libname, pkgname)
    error: Failed to locate any version of JAGS version 4

    The rjags package is just an interface to the JAGS library
    Make sure you have installed JAGS-4.x.y.exe (for any x >=0, y>=0) from
    http://www.sourceforge.net/projects/mcmc-jags/files

    When I try to set JAGS_HOME I get this output:

    Sys.setenv(JAGS_HOME=“C:\Program Files\JAGS\JAGS-4.3.0”)
    Error: unexpected input in "Sys.setenv(JAGS_HOME=“"

    Any help would be greatly appreciated as I've tried a million things and none seem to work.
    Cordially,
    Jean Velez

     
    • Wang-Zhong Li

      Wang-Zhong Li - 2021-10-03

      Sys.setenv(JAGS_HOME="C:\Program Files\JAGS\JAGS-4.3.0")
      library("rjags")

      The above code works for me. You need to make sure that JAGS should be installed in the corresponding folders (C:\Program Files\JAGS\JAGS-4.3.0).

       
  • Wang-Zhong Li

    Wang-Zhong Li - 2021-10-03

    Or try: Sys.setenv(JAGS_HOME="C:\Program Files\JAGS\JAGS-4.3.0")

     
  • Jean Carlos Velez Rodriguez

    JAGS is correctly installed in those folders. I have uninstalled and reinstalled a couple of times now. The command is still not working.

    Sys.setenv(JAGS_HOME="C:\Program Files\JAGS\JAGS-4.3.0")
    Error: '\P' is an unrecognized escape in character string starting ""C:\P"

    I don't really know what else to do.

     
    • Wang-Zhong Li

      Wang-Zhong Li - 2021-10-08

      Correct:
      Sys.setenv(JAGS_HOME="C:/Program Files/JAGS/JAGS-4.3.0")

      Incorrect:
      Sys.setenv(JAGS_HOME="C:\Program Files\JAGS\AGS-4.3.0")

      Make sure that field separator "/" is correct. It should be "/" but not "\". If you select to use "\", "\" should be double type as "\"

       
  • Jean Carlos Velez Rodriguez

    That worked! I feel so dumb. Thank you immensely!!

    Best,
    Jean Velez

     
  • Matt Tietbohl

    Matt Tietbohl - 2021-10-13

    Hi folks!

    Tuning in late to this - I have the same issue, can install rjags, but it doesn't run because it can't find JAGS. My versions are listed below and are all updated to the latest versions.
    JAGS Version: 4.3.0
    RStudio Version: 2021.09.0 Build 351
    Installation of rjags is okay using the following command:
    install.packages('rjags',configure.args="--enable-rpath")

    Error messages recopied below:
    library(rjags)
    Warning: package ‘rjags’ was built under R version 4.0.5
    Error: package or namespace load failed for ‘rjags’:
    .onLoad failed in loadNamespace() for 'rjags', details:
    call: fun(libname, pkgname)
    error: The environment variable JAGS_HOME is set to
    C:/ProgramData/Microsoft/Windows/Start Menu/Programs/JAGS/JAGS-4.3.0
    but no JAGS installation can be found there

    If I go to where JAGS is installed, the path is:
    C:\ProgramData\Microsoft\Windows\Start Menu\Programs\JAGS

    I used the above lines shared to try and solve this problem, but to no avail:

    Sys.setenv(JAGS_HOME="C:/ProgramData/Microsoft/Windows/Start Menu/Programs/JAGS/JAGS-4.3.0")
    Error: unexpected '/' in "Sys.setenv(JAGS_HOME=C:/"

    Corrected to:
    Sys.setenv(JAGS_HOME="C:\ProgramData\Microsoft\Windows\Start Menu\Programs\JAGS\JAGS-4.3.0")
    Error: '\P' is an unrecognized escape in character string starting ""C:\P"

    Corrected to:
    Sys.setenv(JAGS_HOME="C:\ ProgramData\ Microsoft\ Windows\ Start Menu\ Programs\ JAGS\ JAGS-4.3.0")
    This doesn't yield any errors, but when I try to load rjags I get the following:
    library(rjags)
    Warning: package ‘rjags’ was built under R version 4.0.5
    Error: package or namespace load failed for ‘rjags’:
    .onLoad failed in loadNamespace() for 'rjags', details:
    call: fun(libname, pkgname)
    error: The environment variable JAGS_HOME is set to
    C: ProgramData Microsoft Windows Start Menu Programs JAGS JAGS-4.3.0
    but no JAGS installation can be found there

    This is the same as above, but the / are left out for some reason.

    Unsure of what to try next, any thoughts/insight would be much appreciated! :)

     

    Last edit: Matt Tietbohl 2021-10-13
    • Wang-Zhong Li

      Wang-Zhong Li - 2021-10-13

      Sys.setenv(JAGS_HOME="C:/ProgramData/Microsoft/Windows/Start Menu/Programs/JAGS")

      Above code may works. Make sure that field separator "/" is correct. It should be "/" but not "\".

       
  • Michael  Seo

    Michael Seo - 2021-10-13

    The new version of rjags updated today should solve the problem. (version 4-12)
    https://cran.r-project.org/web/packages/rjags/index.html

    Thanks Martyn! Always a big fan of your package :)

     
  • Matt Tietbohl

    Matt Tietbohl - 2021-10-13

    Problem resolved it seems! I think JAGS was in the wrong location, and once I moved that and corrected my code to match yours Wang-Zhong, it worked!

    Sys.setenv(JAGS_HOME="C:/Program Files/JAGS/JAGS-4.3.0")

    Thanks for the help to you both! :)

     
  • Hakem Ben Addi

    Hakem Ben Addi - 2022-05-12

    Hi,

    I have a similar issue installing rjags from Rstudio:

    *** arch - i386

    C:/Rtools/mingw_32/bin/g++ -I"C:/PROGRA~1/R/R-35~1.1/include" -DNDEBUG -I"/include" -O2 -Wall -mtune=generic -c jags.cc -o jags.o
    jags.cc:25:21: fatal error: Console.h: No such file or directory
    #include <console.h></console.h>

    The trick using Sys.setenv(JAGS_HOME="") does not work as variable JAGS_HOME does not exist. (first time install).

    JAGS has been installed in folder Program Files.

    Any advice would be appreciated.

     
  • Jessica Guo

    Jessica Guo - 2023-03-24

    Hi all, I'm having a similar problem after updating to R 4.2.3 Shortstop Beagle. But the error isn't that it can't find JAGS. Rather:
    Error: package or namespace load failed for ‘rjags’: .onLoad failed in loadNamespace() for 'rjags', details: call: inDL(x, as.logical(local), as.logical(now), ...) error: unable to load shared object 'C:/Users/jessi/AppData/Local/R/win-library/4.2/rjags/libs/x64/rjags.dll': LoadLibrary failure: The specified procedure could not be found.

    When I tried the same in R rather than RStudio, I got the additional pop-up warning message of:
    "The procedure entry point ZN4jags5Model12rngFactoriesB5css11EV culd not be located in the dynamic link library". Please advise.

     
    • Martyn Plummer

      Martyn Plummer - 2023-03-24

      What did you upgrade from? If you were using R 4.1.3 or earlier you then need to reinstall JAGS.

      The compiler used to build R changed with release 4.2.0 and unfortunately the compiler used for JAGS has to match the one used for R. Upgrading to JAGS 4.3.1 should solve this.

      https://sourceforge.net/projects/mcmc-jags/files/JAGS/4.x/Windows/JAGS-4.3.1.exe/download

       
      • Jessica Guo

        Jessica Guo - 2023-03-28

        Thanks Martyn, that was the problem. I upgraded from R 4.1.2 and didnt' realize that JAGS 4.3.1 was out. What a huge help!

         
  • javier

    javier - 2023-04-25

    Hi! I am trying to install JAGS 4.3.1 for my R 4.2.2 on my MacOs Ventura. I am following the instructions in "jags_installation_manual.pdf", and I am running in some issues with the first script.

    i am trying to run "configure", but it says that my system is incompatible:

    JAGS-4.3.1 % ./configure 
    checking build system type... Invalid configuration `arm64-apple-darwin20.0.0': machine `arm64-apple' not recognized
    configure: error: /bin/sh ./config.sub arm64-apple-darwin20.0.0 failed
    
     
    • Matt Denwood

      Matt Denwood - 2023-04-25

      Hi Javier

      Unless you really want to compile from source (e.g. because you have also compiled R from source), then I would recommend using the official JAGS 4.3.1 installer from https://sourceforge.net/projects/mcmc-jags/files/JAGS/4.x/Mac%20OS%20X/ (this is binary compatible with the official version of R 4.2.2). Otherwise you can have a look at the R42_compile_script.sh file at https://sourceforge.net/projects/mcmc-jags/files/JAGS/4.x/Mac%20OS%20X/extras/ which gives full details of how to compile a binary-compatible version of JAGS for R 4.2.x, which has been tested on Big Sur (x86_64 and arm64).

      I haven't seen that configure error before but then I am still on Big Sur on my arm64 laptop, as my old Desktop is stuck on Big Sur and I prefer to keep consistent OS versions between my machines. If you still see that configure error with the compile script provided then please let me know - at some point soon I will try to compile JAGS under Ventura running on a VM, and then update the installation manual with whatever changes are needed.

      Cheers,

      Matt

       
  • Matt Denwood

    Matt Denwood - 2023-04-25

    For future readers: please use https://sourceforge.net/p/mcmc-jags/discussion/610037/thread/115edca29d/ for installation problems of JAGS on macOS, rather than this (rather old and cross-platform) thread on rjags.

     

Log in to post a comment.