Error: package or namespace load failed, object ... not found - r

I am running a new install of R (3.5.0) and RStudio (1.1.414). [Note I have now updated to 3.5.1 and 1.1.453 and am still experiencing the issues below with the exception of the "built under R version 3.5.1" warning messages]
I have installed the rlang package using install.packages("rlang") without encountering any issues but when I attempt to load the package I get the following error
Error: package or namespace load failed for ‘rlang’:
.onLoad failed in loadNamespace() for 'rlang', details:
call: dots_list(...)
error: object 'rlang_dots_list' not found
In addition: Warning message:
package ‘rlang’ was built under R version 3.5.1
I've uninstalled and reinstalled rlang (closing restarting RStudio in between each command) and am still encountering this error.
I am also encountering a set of similar (although possible totally unrelated) issue with other packages
RStudio provides the following warning every startup
[Workspace loaded from ~/.RData]
Error in yaml.load(readLines(con), error.label = error.label, ...) :
object 'C_unserialize_from_yaml' not found
Error in yaml.load(readLines(con), error.label = error.label, ...) :
object 'C_unserialize_from_yaml' not found
library(devtools) gives the following errors
Error: package or namespace load failed for ‘devtools’ in FUN(X[[i]], ...):
no such symbol digest in package //[redacted]/My
Documents/R/win-library/3.5/digest/libs/x64/digest.dll
In addition: Warning message:
package ‘devtools’ was built under R version 3.5.1
Someone on twitter asked for the results of packageDescription("rlang")
I've copied the output below in case it helps with troubleshooting.
Package: rlang
Version: 0.2.1
Title: Functions for Base Types and Core R and 'Tidyverse' Features
Description: A toolbox for working with base types, core R features like the condition system, and core
'Tidyverse' features like tidy evaluation.
Authors#R: c( person("Lionel", "Henry", ,"lionel#rstudio.com", c("aut", "cre")), person("Hadley", "Wickham",
,"hadley#rstudio.com", "aut"), person("RStudio", role = "cph") )
License: GPL-3
LazyData: true
ByteCompile: true
Depends: R (>= 3.1.0)
Suggests: crayon, knitr, methods, pillar, rmarkdown (>= 0.2.65), testthat, covr
RoxygenNote: 6.0.1
URL: http://rlang.tidyverse.org, https://github.com/r-lib/rlang
BugReports: https://github.com/r-lib/rlang/issues
NeedsCompilation: yes
Packaged: 2018-05-30 13:14:55 UTC; lionel
Author: Lionel Henry [aut, cre], Hadley Wickham [aut], RStudio [cph]
Maintainer: Lionel Henry <lionel#rstudio.com>
Repository: CRAN
Date/Publication: 2018-05-30 14:23:07 UTC
Built: R 3.5.1; x86_64-w64-mingw32; 2018-07-02 15:08:55 UTC; windows
-- File: [redacted]/My Documents/R/win-library/3.5/rlang/Meta/package.rds

You have 3 different warnings (digest, yaml, and rlang) that each indicate that a package DLL file is corrupted. You are doing something very wrong when installing your packages.
The most common cause of this problem is trying to update a package while it is loaded in R (possibly in another process!). It could also be caused by a bad antivirus program that locks the dll which prevents it from being updated. Please try the following steps:
Quit all R/Rstudio sessions. Check in taskmgr that no Rterm or Rgui process is running.
Delete the folders yaml, rlang and digest inside Documents\R\win-library\3.5\ and also inside C:\Program Files\R\R-3.5.x\library\ if they exists there as well.
Start R to confirm they are gone. Running library(yaml) or library(rlang) should give an error e.g: there is no package called ‘yaml’. Quit R.
Start a new R and run: install.packages(c("yaml", "rlang", "digest"))
Pay close attention to the output, especially the final lines. If you see a warning like below the installation got corrupted and you should remove the package!

Answering my own question in case anyone else encounters a similar issue in the future...
Working with my work IT department we have now tied this to custom permissions on my workstation that mean that R packages can only be run to pre-specified libraries (in my case "C:\R\R-3.4.3\library").
Installing packages directly into that location fixes the issue but is not desirable for all the reasons that people might want to use custom locations (e.g. running multiple versions of the same package, keeping separate libraries for some projects).
As such there are two solutions that may be more or less attainable given your own IT system.
Convince your IT department to relax the permissions for R packages
to allow custom library locations.
Give up and run everything from the "permitted" library location (e.g. C:\R\R-3.4.3\library)
Raise a support ticket every time you need to install a package into a custom location and hope that IT eventually gives in.

This sort of problems almost always comes from a bug in R on Windows: If you reinstall a package that includes compiled code, and if that package is already loaded in R, the DLL will not get updated.
Please try reinstalling rlang on a fresh session. Sometimes packages get loaded automatically at startup from .RProfile and you can check this by calling sessionInfo() after starting up.

Related

Install R package from GitHub in package vignette

I've built an R package and it's available on CRAN. I am updating one of the vignettes and I would like to install a package from GitHub in the vignette. The R CMD Checks ran smoothly on my machine, but after submission to CRAN I received a message indicating that I need to install the package to a temporary library.
I used this code to attempt to install the package to a temporary directory. The code works on my local machine and the R CMD Checks pass locally (devtools::check() and devtools::check(remote = TRUE)). But the checks fail when run on the CRAN machine (rhub::check_for_cran()).
# adding temp_path to .libPaths
temp_path <- file.path(tempdir(), "gt_folder"); dir.create(temp_path)
lib_path <-.libPaths()
.libPaths(c(lib_path, temp_path))
remotes::install_github("rstudio/gt", lib = temp_path)
gt::gt(mtcars)
This is the error I see from rhub::check_for_cran(). It seems the dependencies are not being handled correctly.
ERROR: dependencies 'lazyeval', 'reshape2', 'scales', 'tibble' are not available for package 'ggplot2'
- removing 'C:/Users/USERVzKWFkopnQ/AppData/Local/Temp/RtmpIjoZQH/working_dir/RtmpiwGvJu/gt_folder/ggplot2'
ERROR: dependencies 'fansi', 'utf8', 'vctrs' are not available for package 'pillar'
- removing 'C:/Users/USERVzKWFkopnQ/AppData/Local/Temp/RtmpIjoZQH/working_dir/RtmpiwGvJu/gt_folder/pillar'
The downloaded source packages are in
'C:\Users\USERVzKWFkopnQ\AppData\Local\Temp\RtmpIjoZQH\working_dir\RtmpiwGvJu\downloaded_packages'
ERROR: dependencies 'checkmate', 'commonmark', 'dplyr', 'fs', 'ggplot2', 'sass', 'scales', 'tibble', 'tidyselect' are not available for package 'gt'
- removing 'C:/Users/USERVzKWFkopnQ/AppData/Local/Temp/RtmpIjoZQH/working_dir/RtmpiwGvJu/gt_folder/gt'
Quitting from lines 18-45 (install_from_github.Rmd)
Error: processing vignette 'install_from_github.Rmd' failed with diagnostics:
there is no package called 'gt'
--- failed re-building 'install_from_github.Rmd'
SUMMARY: processing the following file failed:
'install_from_github.Rmd'
Error: Vignette re-building failed.
Execution halted
Here's a light-weight package with only one function and a vignette illustrating the problem https://github.com/ddsjoberg/pkginstallgh
Here is the note I received from CRAN
Dear maintainer,
Pls see
<https://cran.r-project.org/web/checks/check_results_gtsummary.html>.
The check problems on the Debian systems are caused by attempts to write
to the user library to which all packages get installed before checking
(and which now is remounted read-only for checking).
Having package code which is run as part of the checks and attempts to
write to the user library violates the CRAN Policy's
Packages should not write in the user’s home filespace (including
clipboards), nor anywhere else on the file system apart from the R
session’s temporary directory (or during installation in the location
pointed to by TMPDIR: and such usage should be cleaned up).
In your case, you need to teach remotes::install_github("rstudio/gt") to
install to a temporary library and use it from there.

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.

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

How to find the R version under which an R package was built?

Root of problem:
My environment is RevoREnt 7.3 that is tied with R 3.1.1.
I need to install tidyr package. tidyr needs DBI package.
I installed/loaded DBI (v0.5). R gave warning:
Warning message:
package ‘DBI’ (0.5) was built under R version 3.3.1
After installing/loading DBI (v0.5), my search help function was corrupted with error: i.e.,
"?? yay"in R console gave the following error:
"Error in `[<-`(`*tmp*`, , "name", value = sub("\\.[^.]*$", "", basename(vDB$File))) : subscript out of bounds"
Then, instead of Uninstall/Reinstall RevoREnt, I decided to save my broken RevoREnt (noticing that there are many R user facing corrupted search help function without any solution to mend).
I unload/uninstall DBI from R console, then I deleted the folder of DBI package from R library location via Windows Explorer. I re-run RevoREnt and write "??yay" in console:
My Help Browser (http://127.0.0.1:27971/doc/html/Search?pattern=yay) was opened
"The search string was "yay". No results found." appeared there.
That is: I saved my search help function without uninstalling/Re-installing RevoREnt.
What I did to solve/find:
1. Since I very needeed tidyr package, I decided to install/load DBI package that is compatible with my R 3.1.1. I went CRAN DBI (https://cran.r-project.org/web/packages/DBI/index.html)
There, it writes "Depends: R (≥ 2.15.0)" in DBI page.
Does this mean that DBI (v0.5) was built under R2.15.0?
2. I went to DBI's archieve: https://cran.r-project.org/src/contrib/Archive/DBI/
Tried to find one by one loading and checking the warnings in R console:
Warning message:
package ‘DBI’ (0.5) was built under R version 3.3.1
Warning message:
package ‘DBI’ (0.4) was built under R version 3.1.3
Warning message:
package ‘DBI’ (0.3.1) was built under R version 3.1.2
Eventually, by trial and error, I found DBI 0.3.1 does not corrupt my search help function though it is built under 3.1.2>3.1.1!
Then, I reversed back. This time DBI 0.4 also did not corrupt search help function unexpectedly. DBI 0.5 always continued to corrupt the search help function.
Isn't there any simple way of finding R version under which the packages were built?
The information you want is in the last column ("Built") of the output of installed.packages(), per https://stat.ethz.ch/R-manual/R-devel/library/utils/html/installed.packages.html.
.libPaths() # get the library location
installed.packages(lib.loc = "C://Revolution//R-Enterprise-7.3//R-3.1.1//library")

rpart package installation in R

I am trying to install "rpart" package in R. But I am getting the following error.
> install.packages('rpart')
Warning in install.packages("rpart") :
argument 'lib' is missing: using '/home/sandeep/R/i686-pc-linux-gnu-library/2.11'
Warning message:
In getDependencies(pkgs, dependencies, available, lib) :
package ‘rpart’ is not available
Can anyone please tell whats the error about? How to solve?
A tip to start: If you're not sure whether you have a package already, you can use eg the function find.package() to check:
> find.package('rpart')
[1] "D:/R/library/rpart"
> find.package('lololool')
Error in find.package("lololool") : there is no package called 'lololool'
The problem is not so much that it is installed by default. It can be downloaded and installed from CRAN without problem using install.packages('rpart'), but if you check at the package page on CRAN, you see a very important line:
Depends: R (≥ 2.13.0), graphics, stats, grDevices
which tells you that it is only available for R 2.13 and following versions. From your error, I deduce you still run 2.11. Quite some packages are not available for that old R version from CRAN any more, so you better update your R. Otherwise you'll run into this problem more often.
Be aware that if you run Debian, you'll have to do a bit more effort, as the default R in debian is always outdated. Just in case, you find the directions to do that here.
I found that once I restarted RStudio that I was able to install the package and find.package() showed I did, now, have the packages.

Resources