Problems installing rjags and JAGS on Mac OsX 10.5.8 - r

I am having issues getting rjags the R package for R to call JAGS (Just Another Gibbs Sampler http://www-ice.iarc.fr/~martyn/software/jags/ ).
I am running Mac Os X. 10.5.8 Leopard and using R64 2.12.1. I compiled JAGS from the command line. Then I installed rjags in the R command line.
install.packages(rjags)
When I try to call rjags within R, I get the following error.
> library(rjags)
Error : .onLoad failed in loadNamespace() for 'rjags', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/Library/Frameworks/R.framework/Versions/2.12/Resources /library/rjags/libs/x86_64/rjags.so':
dlopen(/Library/Frameworks/R.framework/Versions/2.12/Resources/library/rjags/libs/x86_64/rjags.so, 10): Library not loaded: /usr/local/lib/libjags.2.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/2.12/Resources/library/rjags/libs/x86_64/rjags.so
Reason: no suitable image found. Did find:
/usr/local/lib/libjags.2.dylib: mach-o, but wrong architecture
/usr/local/lib/libjags.2.dylib: mach-o, but wrong architecture
Error: package/namespace load failed for 'rjags'
I am guessing there is some issue with rjags referencing an unknown file in the library, but I am not sure. I am a fairly novice at the command line and messing around with directories, so any help would be much appreciated.

I found (after downloading and installing the dmg from SourceForge) that the following commands worked for me:
wget http://cran.r-project.org/src/contrib/rjags_2.2.0-4.tar.gz
wget http://cran.r-project.org/src/contrib/R2jags_0.02-15.tar.gz
sudo R --with-jags-modules=/usr/local/lib/JAGS/modules-2.2.0 CMD INSTALL rjags_2.2.0-4.tar.gz
sudo R --with-jags-modules=/usr/local/lib/JAGS/modules-2.2.0 CMD INSTALL R2jags_0.02-15.tar.gz
sudo R --with-jags-modules=/usr/local/lib/JAGS/modules-2.2.0 --arch=i386 CMD INSTALL rjags_2.2.0-4.tar.gz
sudo R --with-jags-modules=/usr/local/lib/JAGS/modules-2.2.0 --arch=x86_64 CMD INSTALL rjags_2.2.0-4.tar.gz
They certainly aren't all necessary, but they were sufficient!

I had the same problem while running Rstudio 0.97.237 and R 2.15.2. The issue had something to do with JAGS.
The fix: Update to JAGS 3-3 by downloading and installing it from here.

I encountered the error: unable to load shared object '/Library/Frameworks/R.framework/Resources/modules//R_X11.so': on my Mac and DuckDuckGo led me to this post. I was using R from the command line, so I can't speak to how it works with RStudio although I'm pretty sure it's the fix for that too. I updated JAGS from the SourceForge link provided in another answer. I can at least verify that it worked for me, though the developer was unsigned (I needed to ignore a MacOS warning during the installation procedure).

Related

R: install uroot package in ubuntu

I am trying to install the forecast package which depends on uroot, which apparently have been written to require a GPU?
install.packages("uroot") yields the following error. Has anyone found this issue and may suggest a work around? I am using ubuntu 16.04.
I have the file in question located here: /usr/local/cuda-8.0/ and I added to my path export PATH=/usr/local/cuda-8.0/:$PATH
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/home/rstudio2/R/x86_64-pc-linux-gnu-library/3.2/uroot/libs/uroot.so':
libcudart.so.8.0: cannot open shared object file: No such file or directory
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/home/rstudio2/R/x86_64-pc-linux-gnu-library/3.2/uroot’
Warning in install.packages :
installation of package ‘uroot’ had non-zero exit status
Just in case this is useful for someone, I stumbled with the same problem trying to install "imputeTS" with R version 3.5.1 on Fedora 27 with CUDA 10.0 correctly installed an setted in PATH.
for me it just happened that I was running install.package("imputeTS") (which depends on forecast) in a R console as root, installing the packages to the user home solved the problem. It's seems that the libraries are searched in different places according to the user running the script, it's important to note that.
I just migrated to Linux. On an Ubuntu 18.04 setup, using install.packages with dependencies set to TRUE succeeded with no complaints. (No GPU on mu box.)
install.packages("forecast", dep=TRUE)
# there are quite a few dependencies and you happened to be missing one
packageDescription()
#-----------includes this line----------
Imports: colorspace, fracdiff, ggplot2 (>= 2.2.1), graphics, lmtest,
magrittr, nnet, parallel, Rcpp (>= 0.11.0), stats,
timeDate, tseries, urca, uroot, zoo
You can try to modify file "/etc/rstudio/rserver.conf", add "LD_LIBRARY_PATH" env, like:
rsession-ld-library-path=/usr/local/cuda/lib64
Actually, When you open session of "RStudio Server" from browser, the session does't get env from the ".bashrc".

Getting gputools and gmatrix in R to run smoothly on Linux

I am having trouble getting R to recognize gmatrix for R, running through Rstudio. My details are below.
Things that are accomplished and DONE:
install of openSuse Tumbleweed x86_64
install of NVIDIA graphics driver 361.42
install of CUDA 7.5 & symbolic link for /usr/local/cuda
set LD_LIBRARY_PATH & PATH
R 3.2.5
RStudio 0.98.501-1.62
patched /usr/local/cuda/include/host_config.h, line: 115 by increasing the "4"'s to "5"'s (this pertains to the gcc compiler)
install package gputools
~ partial install of package gmatrix
*I had to edit the host_config.h file because cuda is not supported for the gcc compiler that Tumbleweed ships with. I basically broke the evaluation that checks for version and set it to 5.9 instead of 4.9. Was this a supremely naive thing to do?
Things not Done, help required:
-I wasn't able to install gmatrix properly. I got R to install by manually adding the LD & PATH directories using the Sys.setenv()
> Sys.setenv("LD_LIBRARY_PATH"="/usr/lib64/R/lib:/lib:/usr/local/lib64:/usr/local/cuda/lib64")
> Sys.setenv("PATH"="/home/eamergent/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:/usr/local/cuda/bin")
However, I am unable to load the gmatrix package, yet gputools works fine:
> library(gputools) "no issues"
> library(gmatrix)
> Error in dyn.load(file, DLLpath = DLLpath, ...) : unable to load shared object '/home/eamergent/R/x86_64-suse-linux-gnu-library/3.2/gmatrix/libs/gmatrix.so':libcudart.so.7.5: cannot open shared object file: No such file or directory Error: package or namespace load failed for ‘gmatrix’
*The Error makes it seem that libcudart.so.7.5 is to blame
However,
/usr/local/cuda/lib64/libcudart.so.7.5 does in fact exist:
> eamergent#linux-pnx7: ls /usr/local/cuda/lib64/libcuda
libcudadevrt.a libcudart.so libcudart.so.7.5 libcudart.so.7.5.18 libcudart_static.a
*I used tab to get a shorter list. there are many more in lib64
Any ideas on how to get R to recognize the already installed gmatrix package? Or how to properly reinstall without using the R environment path fix that I used above?
I had the same issue on Ubuntu 14.04 where the system and R (Sys.setenv()) shared library paths were set properly, but R failed to load the CUDA shared library. What worked was to set the CUDA shared library path using ldconfig.
as root or prefix commands with sudo:
# echo "/usr/local/cuda/lib64/libcuda" > /etc/ld.so.conf.d/cuda.conf
# ldconfig
then
# R
> install.packages("gmatrix")
or if gmatrix is already installed
# R
> library(gmatrix)
> gtest()

Error while installing "nloptr_1.0.4.tar.gz" from local

When i tried to install nloptr_1.0.4.tar.gz from local, It needed another unix library nlopt-2.4.2.tar.gz which I got it resolved from the following thread Error while installing a tar.gz package in R
But, even after that the package is not getting installed
It throws the following error,
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/home/cloudera/R/x86_64-redhat-linux-gnu-library/3.2/nloptr/libs/nloptr.so':
/home/cloudera/R/x86_64-redhat-linux-gnu-library/3.2/nloptr/libs/nloptr.so: undefined symbol: nlopt_set_maxtime
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/home/cloudera/R/x86_64-redhat-linux-gnu-library/3.2/nloptr’
For the above error, I got a lead from the following link:https://cran.r-project.org/web/packages/ROracle/INSTALL
and http://ab-initio.mit.edu/wiki/index.php/NLopt_Installation
Based on the above links, I had to set LD_LIBRARY_PATH variable to /usr/local/lib and /usr/local/include
Even after setting the above Environment variable, R CMD INSTALL nloptr_1.0.4.tar.gz is not getting installed and throwing the same error.
The fix is easy. On a Debian/Ubuntu system do
sudo apt-get install libnlopt-dev
as you always need the development package to compile a given library. It will then be found, and nloptr will install without a hitch.
Similarly on a RH/FC/CentOS with rpms.
Now, when I helped Jelmer rewrite the configuration for nloptr, we did make sure it worked both ways: with an install nlopt library, and without. You seem to stuck in the middle with one that is installed, but different ("missing symbol"). If you cannot uninstall that 'wrong' libnlopt, I would recommend altering the nloptr sources to not check for it but rather always build itself against a copy of nlopt 2.4.2 which it will download and compile statically.

Installing rjags in R on OSX Mavericks

I am trying to install the package "rjags" in R but am running into the following error:
Loading required package: rjags
Error : .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.1/Resources/library/rjags/libs/rjags.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.1/Resources/library/rjags/libs/rjags.so, 10): Symbol not found: __ZN5RangeC1ERKSt6vectorIiSaIiEES4_
Referenced from: /Library/Frameworks/R.framework/Versions/3.1/Resources/library/rjags/libs/rjags.so
Expected in: /usr/local/lib/libjags.3.dylib
in /Library/Frameworks/R.framework/Versions/3.1/Resources/library/rjags/libs/rjags.so
Error: package ‘rjags’ could not be loaded
I've installed JAGS on my Mac (running Mavericks), and I am running R-3.1.2. I've tried installing from the url using the devtools package, as recommended by this site:
install_url("http://sourceforge.net/projects/mcmc-jags/files/rjags/3/rjags_3-2.tar.gz",
args="--configure-args='--with-jags-include=/Users/casallas/homebrew/opt/jags/include/JAGS
--with-jags-lib=/Users/casallas/homebrew/opt/jags/lib'
"
)
I've also gone through the instructions on this other site , trying the different versions of JAGS and receive the same error. I'm at a loss for what to try next and am sure the solution is simple. Does anyone have any insights? Thanks so much!
I found that while I was unable to install rjags from the url, if I installed the package from source on my computer I was successful. I did this by downloading the appropriate package from here (which for me was rjags_3-14.tgz) and ran the following command:
install.packages(path_to_file, repos = NULL, type="source")
The error:
Symbol not found: __ZN5RangeC1ERKSt6vectorIiSaIiEES4_
Is (nearly) always caused by a mismatch between standard libraries between the Mavericks build of R (actually rjags) and Snow Leopard build of JAGS (or vice versa). For more info see the instructions at https://sourceforge.net/projects/mcmc-jags/files/JAGS/3.x/Mac%20OS%20X/
I'm guessing that compiling the package yourself from source worked because it matched the version of the standard library that JAGS is using, but this will no longer match the version that R is using (although I'm not sure if this is a major problem, it is not recommended). You would be better to match the builds of R and JAGS and use the pre-built rjags library from CRAN.
It is interesting that you say you have tried both builds of JAGS but I suggest trying again along these lines:
1) Use .Platform$pkgType in R to confirm if it you are using mac.binary (SL) or mac.binary.mavericks (Mavericks) - or failing that re-install the Mavericks binary of R from CRAN
2) Exit R
3) Re-install the appropriate version of JAGS
4) Re-open R and re-install the rjags library from CRAN
5) Try library(rjags)
If this doesn't work can you provide more information so I can try and track down a possible problem with the JAGS builds?
Thanks,
Matt

R does not recognize the correct libstdc++.so library

When I try to install the kernlab package on R 2.15.2 on Scientific Linux 5.5, I get the following error message:
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '~/bin/lib64/R/library/kernlab/libs/kernlab.so':
/usr/java/jdk1.6.0_41/jre/../lib/amd64/libstdc++.so.6: version `GLIBCXX_3.4.9' not found (required by ~/bin/lib64/R/library/kernlab/libs/kernlab.so)
R 2.11 is installed on the same system, which installs kernlab just fine. Additionally, the following reports no errors:
ldd -r ~/bin/lib64/R/library/kernlab/libs/kernlab.so
So it seems that R simply doesn't manage to use the right libraries. I set LD_LIBRARY_PATH to /usr/local/gcc-4.6.0/lib64/, which is where the working version of libstdc++.so.6 seems to be, but that did not help.
How can it be that R refuses to use the right libraries? And how can I make it use the correct one?
How can it be that R refuses to use the right libraries?
Something else in the process must be loading the older libstdc++.so before the R shared lib gets loaded. I'm surprised LD_LIBRARY_PATH doesn't help though.

Resources