Cannot install rstanarm (R crashes) - r

A similar question was asked here, but I tried the code Tiago Lubiana posts there, to no avail.
I haven't been able to install rstanarm after several attempts. R keeps crashing during the installation.
I did install rstan by running
install.packages("rstan", repos = "https://cloud.r-project.org/", dependencies = TRUE)
When I want to install rstanarm, nothing seems to work, though. I've tried the following:
1) install.packages("rstanarm"): R crashes and installs a folder called 00LOCK-rstanarm, plus the corresponding rstanarm folder. When I open R, rstanarm is there, but after running library(rstanarm), I get
Error: package or namespace load failed for ‘rstanarm’ in library.dynam(lib, package, package.lib):
shared object ‘rstanarm.so’ not found
By running install.packages("rstanarm") again, I get:
ERROR: failed to lock directory ‘/home/nalerive/R/x86_64-pc-linux-gnu-library/3.5’ for modifying
Try removing ‘/home/nalerive/R/x86_64-pc-linux-gnu-library/3.5/00LOCK-rstanarm’
Warning in install.packages :
installation of package ‘rstanarm’ had non-zero exit status
Deleting that folder has not solved the problem (but see here for a similar error with another package).
2) From here, running
if (!require(devtools)) { install.packages("devtools")
library(devtools) }
install_github("stan-dev/rstanarm", build_vignettes = FALSE)
leads to R crashing again, and the same folders as in 1) are installed. I also get the same error by running library("rstanarm"), namely:
Error: package or namespace load failed for ‘rstanarm’ in library.dynam(lib, package, package.lib):
shared object ‘rstanarm.so’ not found
3) Following this post I tried
install.packages("rstanarm", dependencies = TRUE, repos="http://cran.rstudio.com/", INSTALL_opts = c('--no-lock'))
and R keeps crashing.
I've tried more things, like removing the 00LOCK-rstanarm folder by means of unlink("/home/nalerive/R/x86_64-pc-linux-gnu-library/3.5/00LOCK-rstanarm/", recursive = TRUE); restarting R when indicated; checking my C++ toolchain (as suggested here), etc... but nothing has worked. I really feel hopeless at this point.
I have R version 3.5.2, rstan version 2.19.2, and Linux 4.15.0-1-amd64 #1 SMP Debian 4.15.4-1~mx17+1 (2018-02-23)
Any help will be highly appreciated. Thanks in advance!

Related

Unable to install package Sleuth in R

I've been trying to install the Sleuth package in R all morning and it keeps giving me errors. This is how I tried to install it:
if(!requireNamespace("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("DESeq2")
BiocManager::install ("rhdf5")
install.packages("devtools")
devtools:: install_github("pachterlab/sleuth")
I did use the library() command.
I get the following error messages:
Error: object 'h5write.default' is not exported by 'namespace:rhdf5'
Execution halted
ERROR: lazy loading failed for package 'sleuth'
removing 'C:/Users/31625/OneDrive/Documents/R/win-library/4.1/sleuth'
I was having the same issue and found that there's current an open issue on Github discussing this problem.
Currently there is a workaround which was shared in the same issue on Github:
Run git clone https://github.com/pachterlab/sleuth
Remove the last line in ./sleuth/NAMESPACE which is the h5write.default that raises the error during installation - ignore the warning in the first line
Then in R: devtools::install('./sleuth/')
It worked for me while using Linux - ZorinOS and R 4.1.2 but it should work on Windows as well.
Someone also opened a PR to fix the whole issue but it seems they are not updating the package anymore (unfortunately).

Issue with loading Tidyverse in RStudio

How to do i resolve the following code error?
library(tidyverse)
Error: package or namespace load failed for ‘tidyverse’:
.onLoad failed in loadNamespace() for 'tidyselect', details:
call: is_string(x)
error: object 'rlang_is_string' not found
In addition: Warning message:
package ‘tidyverse’ was built under R version 3.5.3
For persistent errors of type, first, ensure you are working with the latest version of R. The installr package is a very convenient way to do this.
Then, start new R session (ideally, not in RStudio).
Uninstall tidyverse, tidyselect, and rlang
# if you are using multiple libraries, you may need to specify libpath,
# using the following: lib="~/R/win-library/3.6"
# you can check using the .libPaths() command
remove.packages("rlang")
remove.packages("tidyselect")
remove.packages("tidyverse")
and, reinstall them one by one with dependencies = TRUE
install.packages("rlang", dependencies = TRUE)
install.packages("tidyselect", dependencies = TRUE)
install.packages("tidyverse", dependencies = TRUE)
That should do it.
I also encounter a similar problem like you, which I'm unable to load the tidyverse too.
Hope this discuss from the tidyverse github issues maybe relevant to you.
https://github.com/tidyverse/googledrive/issues/275
Here's one of our typical explanations of this. Note that this is not specific to googledrive or rlang. It's an R + Windows gotcha. I suspect for you is rlang (at least).
Please note that on Windows, it is very important to quit or restart
all R processes before upgrading , because if any R process has
loaded, it will keep the .dll file open and the installer will not be
able to overwrite .dll. The error message when this happens is very
easy to overlook, and the new version will be partially installed: the
package description and R code will be updated but the compiled code
(in .dll) will not.

Fail to load libraries after upgrading R to 3.6.0 on Mac

I needed to install the R package quadprog, which only works for R with version 3.6.0. So I installed R (3.6.0 version), and open it with RStudio. But now I failed to load any libraries, even after I installed the packages successfully using install.packages("package_name"). Specifically, the libraries I need to load are caret, forecast and ggplot2. I tried re-installing R but it still does not work. The error message I get is
Error: package or namespace load failed for ‘forecast’ in
dyn.load(file, DLLpath = DLLpath, ...): unable to load shared object
'/Library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp/libs/Rcpp.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp/libs/Rcpp.so,
6): Symbol not found: ___cxa_uncaught_exceptions Referenced from:
/Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libc++.1.dylib
Expected in: /usr/lib/libc++abi.dylib in
/Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libc++.1.dylib
After installing Rcpp package successfully with install.packages("Rcpp") , I still got the message above when I tried library(Rcpp). So I am completely stumbled here...(before upgrades, everything works fine except I cannot install quadprog, so cannot install forecast package as well). Can anyone please help me fix this issue?
Please see below the images showing that the packages are stored in the same directory path of the R.
I read that you need to recompile your old packages after upgrading to newer version of R. Run the following line in your R terminal
update.packages(ask=FALSE,
checkBuilt=TRUE,
repos="https://cloud.r-project.org")
Then
install.packages(c("Rcpp", "caret", "forecast", "ggplot2", "quadprog"),
dependencies=TRUE,
repos="https://cloud.r-project.org")
Had similar issue, restart R session and install Rcpp from source
install.packages("Rcpp", type="source")
then load the library
library(Rcpp)
if still getting the error, restart R session and try loading library again.
I ended up by getting and then google searching the exact error code :). I fixed it by installing the latest version of R from CRAN along with the latest version of Rstudio. What I think happened was that when I updated some packages R and Rstudio were out of sync.

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".

cannot load rms package

I'm working with R, I have installed the library 'rms' but I have the follow error:
> library(rms)
Error in library.dynam(lib, package, package.lib) :
DLL ‘colorspace’ not found: maybe not installed for this architecture?
Errore: package ‘ggplot2’ could not be loaded
What can I do?
If you install from base R and wish to install a package and all its dependencies, you need to use the argument dependencies = TRUE. From ?install.packages:
"dependencies = TRUE ... this installs all the packages needed to run pkgs, their examples, tests and vignettes (if the package author specified them correctly).
Hence,
install.packages("rms",dependencies = TRUE)
should do the trick.
The answer offered so far (without any upvotes so far) is useful, but incomplete. It is sometimes sufficient to execute install.packages() with dependencies = TRUE, but if the missing package is a dependency of a dependency, then install.package is not "smart" enough to recognize that fact. The ggplot2 package is in the "Depends:" line of the rms package DESCRIPTION file, but colorspace is not. Sometimes the end-user simply needs to read the error message and install the missing dependencies.
In this case, however, it appears that there may have been a version mismatch of packages and R.

Resources