Menu

#38 Unable to load rjags in R.3.0.2.

v1.0_(example)
open
1
2022-12-28
2015-05-05
Anonymous
No

Hello,

I'm trying to install rjags on Win7, R version 3.0.2.
JAGS version is 3.4.0.

In my computer, rjags is working fine with R version 2.15.1 (rjags_3-13, coda_0.16-1)

With v.3.0.2, I receive: (coda_0.17-1)

library(rjags)

Error : .onLoad failed in loadNamespace() for 'rjags', details:
call: packageVersion(pkg, lib)
error: package ‘rjags’ not found
In addition: Warning message:
package ‘rjags’ was built under R version 3.0.3
Error: package or namespace load failed for ‘rjags’

I went through the messages here, but I cannot locate any possible reason.

Any help would be appreciated.

Ath.Tsakonas

Related

Bug reports: #38

Discussion

1 2 > >> (Page 1 of 2)
  • Martyn Plummer

    Martyn Plummer - 2015-05-05

    You are not using the latest version of R (3.2.0) and so do not have access to the latest version of rjags (3-15). Try upgrading.

     
  • Anonymous

    Anonymous - 2015-05-05

    Thank you for your prompt reply.

    I understand that the latest version should ensure a better compatibility. As long as this concerns myself, I'm running R on a controlled environment (e.g. not as an admin) and therefore I am not able to update the R version on-the-fly (needs ticket to IT, and time for evaluation, and re-installation of libraries, then further evaluation on existing running code, etc.). In other words, it can merely be a distant option.

    On the other hand, I read on CRAN rjags specifications, that rjags 3-15 requires:

    • R (≥ 2.14.0), coda (≥ 0.13)

    If this compatibility issue is unresolved otherwise, shouldn't that requirement reference be changed to R (≥ 3.0.2), to prevent future misunderstandings with the rest CRAN users?

    Many thanks again,

    Ath.Tsakonas

     
  • Martyn Plummer

    Martyn Plummer - 2015-05-05

    Sorry, my mistake. I thought rjags_3-15 would not be available for R 3.0.2 but checking the CRAN web site I see that it is.

    It looks like you have a broken installation of rjags. Try typing

    packageDescription("rjags")

    at the prompt and see what happens.

     
  • Anonymous

    Anonymous - 2015-05-06

    Hello,

    Rjags won't load. The following is the returned output.

    library(rjags)
    Error : .onLoad failed in loadNamespace() for 'rjags', details:
    call: packageVersion(pkg, lib)
    error: package ‘rjags’ not found
    In addition: Warning message:
    package ‘rjags’ was built under R version 3.0.3
    Error: package or namespace load failed for ‘rjags’

    packageDescription("rjags")

    [1] NA
    Warning message:
    In packageDescription("rjags") : no package 'rjags' was found

    NOT SHOWN IN sessionInfo() as well

    sessionInfo()
    R version 3.0.2 (2013-09-25)
    Platform: i386-w64-mingw32/i386 (32-bit)

    locale:
    [1] LC_COLLATE=English_United Kingdom.1252
    [2] LC_CTYPE=English_United Kingdom.1252
    [3] LC_MONETARY=English_United Kingdom.1252
    [4] LC_NUMERIC=C
    [5] LC_TIME=English_United Kingdom.1252

    attached base packages:
    [1] stats graphics grDevices utils datasets methods base

    other attached packages:
    [1] coda_0.17-1

    loaded via a namespace (and not attached):
    [1] grid_3.0.2 lattice_0.20-31 tools_3.0.2

    ROOT DIR FOR JAGS IS SET

    Sys.getenv('JAGS_ROOT')
    [1] "C:\Users\XXXXXX\AppData\Local\JAGS\JAGS-3.4.0"

    PATHS INCLUDED

    .libPaths()
    [1] "J:/R/win-library/Additional" "J:/R/win-library/3.0"
    [3] "C:/Program Files/R/R-3.0.2/library"

    RJAGS IS INSTALLED

    list.files(path ='J:\R\win-library\3.0\rjags')
    [1] "data" "DESCRIPTION" "help" "html" "INDEX"
    [6] "libs" "MD5" "Meta" "NAMESPACE" "R"

    JAGS IS INSTALLED

    list.files(path ='C:\Users\XXXXXX\AppData\Local\JAGS\JAGS-3.4.0')
    [1] "i386" "include" "Uninstall.dat" "Uninstall.exe"
    [5] "x64"

    Ath.Tsakonas

     
  • Martyn Plummer

    Martyn Plummer - 2015-05-06

    This turns out to be a bug in R itself. The packageDescription() function does not work when your library is on a network drive (drive J in your case). I have confirmed this on my own network.

    I shall push a new version of rjags with a workaround, but will also fix the bug in R.

     
  • Anonymous

    Anonymous - 2015-10-11

    Hi!

    I get a similar message with newest version of R and JAGS installed:

    Error : .onLoad failed in loadNamespace() for 'rjags', details:
    call: fun(libname, pkgname)
    error: Failed to locate any version of JAGS version 3

    The rjags package is just an interface to the JAGS library
    Make sure you have installed JAGS-3.0.0.exe or higher from
    http://www.sourceforge.net/projects/mcmc-jags/files

    Error: package or namespace load failed for ‘rjags’

    Do you have any solution ideas for this problem?

     
  • Martyn Plummer

    Martyn Plummer - 2015-10-12

    When you say the newest version of JAGS, do you mean version 4.0.0? Because you then need the corresponding version of the rjags package, i.e. rjags_4-3. It is not yet available from CRAN but you can download it here:

    http://sourceforge.net/projects/mcmc-jags/files/rjags/4/rjags_4-3.zip/download

     
  • Anonymous

    Anonymous - 2015-10-12

    It helped. Thanks friend, you are great. Earlier i wasted hours to find a solution on the google...

     
  • Anonymous

    Anonymous - 2017-06-22

    Hello,

    I use R 3.4.0 and Installed rjags_4-6 on my Windows 7 pc, and jags doesn’t seem to work. The error message I get is:

    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

    Would you help me please?

     
    • Martyn Plummer

      Martyn Plummer - 2017-06-22

      Did you do the thing that the error message asks you to do?

       
      • Anonymous

        Anonymous - 2017-06-23

        I see! It worked. Sorry, my mistake. Thank you very much.

         
  • laura

    laura - 2018-01-07

    Hello
    I am having trouble to load the rjags package on R 3.4.3. The package had downlaoded properly as i can see it on the right side of the RStudio but I am unable to load it

    Error: package or namespace load failed for ‘rjags’:
    .onLoad failed in loadNamespace() for 'rjags', details:
    call: packageVersion(pkg, lib)
    error: package ‘rjags’ not found

    I tried to uninstall R and JAGS multiple times and dowload different versions of JAGS (3 and 4) but none seem to change anything.

    I tried
    devtools::install_url("http://sourceforge.net/projects/mcmc-jags/files/rjags/4/rjags_4-4.tar.gz",
    args="--configure-args='--with-jags-include=/Users/casallas/homebrew/opt/jags/include/JAGS
    --with-jags-lib=/Users/casallas/homebrew/opt/jags/lib'")
    But I get :
    Installation failed: Command failed (1)

    I have also tried installing from the rjags source file:
    install.packages('~/Downloads/rjags_4-6.tar.gz', repos = NULL, type="source")
    But still get the same error message.

    Any ideas?
    Thanks

     
  • Anonymous

    Anonymous - 2018-01-31

    Hi I have exactly the same problem that you Laura, idem R version 3.4.3

     
  • Evelyn Tay

    Evelyn Tay - 2018-09-05

    Hi
    I am having the same problem as Anonymous from 06/05/2015 with this same bug.
    R version 3.5.1 JAGS 4.6.0 RStudio 1.1.456

    install.packages("rjags")
    Installing package into ‘\uniwa.uwa.edu.au/userhome/students3/18719303/My Documents/R/win-library/3.5’
    (as ‘lib’ is unspecified)
    also installing the dependency ‘coda’

    trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/coda_0.19-1.zip'
    Content type 'application/zip' length 320312 bytes (312 KB)
    downloaded 312 KB

    trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.5/rjags_4-6.zip'
    Content type 'application/zip' length 620629 bytes (606 KB)
    downloaded 606 KB

    package ‘coda’ successfully unpacked and MD5 sums checked
    package ‘rjags’ successfully unpacked and MD5 sums checked

    The downloaded binary packages are in
    C:\Users\18719303\AppData\Local\Temp\RtmpMt90l6\downloaded_packages

    library(rjags)
    Loading required package: coda
    Error: package or namespace load failed for ‘rjags’:
    .onLoad failed in loadNamespace() for 'rjags', details:
    call: packageVersion(pkg, lib)
    error: package ‘rjags’ not found
    packageDescription("rjags")
    [1] NA
    Warning message:
    In packageDescription("rjags") : no package 'rjags' was found

    sessionInfo()
    R version 3.5.1 (2018-07-02)
    Platform: x86_64-w64-mingw32/x64 (64-bit)
    Running under: Windows >= 8 x64 (build 9200)

    Matrix products: default

    locale:
    [1] LC_COLLATE=English_Australia.1252 LC_CTYPE=English_Australia.1252 LC_MONETARY=English_Australia.1252
    [4] LC_NUMERIC=C LC_TIME=English_Australia.1252

    attached base packages:
    [1] stats graphics grDevices utils datasets methods base

    other attached packages:
    [1] coda_0.19-1

    loaded via a namespace (and not attached):
    [1] compiler_3.5.1 tools_3.5.1 grid_3.5.1 lattice_0.20-35

    May I have any advice on how to proceed from here?
    I wish to use JAGS in R.

    Thanks!
    Evelyn

     
    • Martyn Plummer

      Martyn Plummer - 2018-09-06

      This looks like a configuration problem with your R library. Can you load the coda package?

      library("coda")
      packageDescription("coda")
      

      If this does not work, then try

      .libPaths()
      

      to see where R is looking for your packages. According to the output, the packages are installed in an SMB-mounted drive:

      \\uniwa.uwa.edu.au/userhome/students3/18719303/My Documents/R/win-library/3.5

      However, I don't think the double backslash SMB notation is going to work when R looks for your library (Backslash causes a lot of problems in strings in R). If the drive is mounted with a drive letter then use that, and make sure you have only forward slashes in the file path, e.g.

      Z:/My Documents/R/winlibrary/3.5

      Let me know if this works.

      Martyn

       
      • Anonymous

        Anonymous - 2018-09-07

        Hi Martyn,

        Thank you for your reply.
        I can load the coda package.

        I found where the rjags package was loaded to and it was in the H drive.
        This is what I tried and got the same error message:

        library("rjags", lib.loc="H:/My Documents/R/win-library/3.5")
        Loading required package: coda
        Error: package or namespace load failed for ‘rjags’:
        .onLoad failed in loadNamespace() for 'rjags', details:
        call: packageVersion(pkg, lib)
        error: package ‘rjags’ not found

        I then tried:

        .libPaths("rjags")

        This showed that neither rjags nor coda were in the System Library.

        Does this shed any light on this problem?

        Thanks!
        Evelyn

         

        Last edit: Martyn Plummer 2018-09-07
        • Martyn Plummer

          Martyn Plummer - 2018-09-07

          This is still very mystifying. Try

          file.access("H:/My Documents/R/win-library/3.5/rjags")
          

          and

          file.access("H:/My Documents/R/win-library/3.5/rjags", 5)
          

          This is the point in the code that loads the rjags package where the error occurs.

           
          • Anonymous

            Anonymous - 2018-09-10

            Hi Martyn

            A colleague found the problem.
            Rstudio was loaded on to the university server which wasn’t allowing packages being installed as I don’t have the admin rights.
            When we loaded Rstudio on to a local disk, rjags loaded fine.

            It wasn’t a bug after all.

            Thank you for your help!
            Evelyn

             

            Last edit: Martyn Plummer 2018-09-10
  • Anonymous

    Anonymous - 2020-10-29

    Hi, if this chain is still active! I'm trying to load Rjags and getting the following error message in RStudio upon calling library(rjags):

    library(rjags)
    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/3.6/Resources/library/rjags/libs/rjags.so':
    dlopen(/Library/Frameworks/R.framework/Versions/3.6/Resources/library/rjags/libs/rjags.so, 10): Library not loaded: /usr/local/lib/libjags.4.dylib
    Referenced from: /Library/Frameworks/R.framework/Versions/3.6/Resources/library/rjags/libs/rjags.so
    Reason: image not found

    I've checked my library and the file '/Library/Frameworks/R.framework/Versions/3.6/Resources/library/rjags/libs/rjags.so'
    is indeed there -- so I don't think the library reference is the problem.

    When I open the file '/Library/Frameworks/R.framework/Versions/3.6/Resources/library/rjags/Meta/package.rds ' ,
    I get the error message:

    Error in load("/Library/Frameworks/R.framework/Versions/3.6/Resources/library/rjags/Meta/package.rds") :
    bad restore file magic number (file may be corrupted) -- no data loaded
    In addition: Warning message:
    file ‘package.rds’ has magic number 'X'
    Use of save versions prior to 2 is deprecated

    I have downloaded the most recent version of JAGS at the link: https://sourceforge.net/projects/mcmc-jags/ (using the website)

    Any suggestions for how to solve this?

    Thank you,
    Abigail

     
  • Mário Mota-Ferreira

    Hello Martin

    I started to have the same problem after I updated Rstudio (i had to, graphics were not working anymore).

    I'm running a Win10 machine with R 4.1.1 and JAGS 4.3.0.

    I got the following error message:

    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
    

    and the packageDescription("rjags") gives the following message:

    Package: rjags
    Version: 4-11
    Date: 2021-09-24
    Title: Bayesian Graphical Models using MCMC
    Authors@R: c(person("Martyn", "Plummer", role=c("aut","cre"),
              email="martyn.plummer@gmail.com"), person("Alexey", "Stukalov", role="ctb"),
              person("Matt", "Denwood", role="ctb"))
    Depends: R (>= 2.14.0), coda (>= 0.13)
    SystemRequirements: JAGS 4.x.y
    URL: https://mcmc-jags.sourceforge.io
    Suggests: tcltk
    Description: Interface to the JAGS MCMC library.
    License: GPL (== 2)
    NeedsCompilation: yes
    Packaged: 2021-09-24 16:43:06 UTC; martyn
    Author: Martyn Plummer [aut, cre], Alexey Stukalov [ctb], Matt Denwood [ctb]
    Maintainer: Martyn Plummer <martyn.plummer@gmail.com>
    Repository: CRAN
    Date/Publication: 2021-09-24 17:50:02 UTC
    Built: R 4.1.1; x86_64-w64-mingw32; 2021-09-29 11:31:06 UTC; windows
    
    -- File: C:/Program Files/R/R-4.1.1/library/rjags/Meta/package.rds 
    

    Can you offer any help?

     
    • Anonymous

      Anonymous - 2021-10-13

      Hello, I m getting the same issue, that i have R 4.1.1 and JAGS 4.2.0 but getting similar so how did you solve it

       
      • Mário Mota-Ferreira

        Had to go back to a previous version (4.0.2)

         
  • Mário Mota-Ferreira

    Just an update.
    It seems the problem is with the R version. I'm able to work with an older version of R (4.0.2)

     

    Last edit: Mário Mota-Ferreira 2021-10-08
    • Martyn Plummer

      Martyn Plummer - 2021-10-13

      The problem was a bug introduced in rjags_4-11. I have fixed it in rjags_4-12, which has just been uploaded to CRAN.

      I made some changes for the new R toolchain, which is 64-bit only, but accidentally broke the code that reads the Windows registry to find JAGS. This bug was not detected by CRAN because they use a hard-coded path to JAGS.

       
      • Mário Mota-Ferreira

        Thanks Martyn!

        Do we need to update R or just rjags?

        Cheers

         
1 2 > >> (Page 1 of 2)

Anonymous
Anonymous

Add attachments
Cancel