Can't load any package in R - r

I am running R under macOS Catalina 10.15.5 (can't update to the newest version because it requires 17GB and it doesn't have so much space).
Yesterday, RStudio stopped working (not loading libraries that used to work for me, like dplyr or tidyverse).
After trying some codes like
update.package(checkBuilt = TRUE)
nothing changed. I have decided to uninstall and install again both R and RStudio, but nothing improved.
Error (e.g.: Tidyverse):
> install.packages("tidyverse", type="binary")
trying URL 'https://cran.rstudio.com/bin/macosx/contrib/4.2/tidyverse_1.3.2.tgz'
Content type 'application/x-gzip' length 420896 bytes (411 KB)
==================================================
downloaded 411 KB
The downloaded binary packages are in
/var/folders/83/1hdhv2r97017s9xxs6yj5hl00000gn/T//Rtmp8tahja/downloaded_packages
> library(tidyverse)
**Error: package or namespace load failed for ‘tidyverse’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):**
** there is no package called ‘vctrs’**
The version I am running:
> version
_
platform x86_64-apple-darwin17.0
arch x86_64
os darwin17.0
system x86_64, darwin17.0
status
major 4
minor 2.2
year 2022
month 10
day 31
svn rev 83211
language R
version.string R version 4.2.2 (2022-10-31)
nickname Innocent and Trusting
> .libPaths()
[1] "/Library/Frameworks/R.framework/Versions/4.2/Resources/library"
> sessionInfo()
R version 4.2.2 (2022-10-31)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.5
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] devtools_2.4.5 usethis_2.1.6
loaded via a namespace (and not attached):
[1] Rcpp_1.0.9 compiler_4.2.2 later_1.3.0 urlchecker_1.0.1 prettyunits_1.1.1 profvis_0.3.7
[7] remotes_2.4.2 tools_4.2.2 digest_0.6.30 pkgbuild_1.3.1 pkgload_1.3.2 memoise_2.0.1
[13] lifecycle_1.0.3 rlang_1.0.6 shiny_1.7.3 cli_3.4.1 rstudioapi_0.14 curl_4.3.3
[19] fastmap_1.1.0 withr_2.5.0 stringr_1.4.1 fs_1.5.2 htmlwidgets_1.5.4 rprojroot_2.0.3
[25] glue_1.6.2 R6_2.5.1 processx_3.8.0 sessioninfo_1.2.2 purrr_0.3.5 callr_3.7.3
[31] magrittr_2.0.3 promises_1.2.0.1 ps_1.7.2 ellipsis_0.3.2 htmltools_0.5.3 mime_0.12
[37] xtable_1.8-4 httpuv_1.6.6 stringi_1.7.8 miniUI_0.1.1.1 cachem_1.0.6 crayon_1.5.2
> packageVersion('tidyverse')
[1] ‘1.3.2’
EDIT
> install.packages("vctrs")
There is a binary version available but the source version is later:
binary source needs_compilation
vctrs 0.5.0 0.5.1 TRUE
Do you want to install from sources the package which needs compilation? (Yes/no/cancel) Yes
installing the source package ‘vctrs’
trying URL 'https://cran.rstudio.com/src/contrib/vctrs_0.5.1.tar.gz'
Content type 'application/x-gzip' length 959562 bytes (937 KB)
==================================================
downloaded 937 KB
* installing *source* package ‘vctrs’ ...
** package ‘vctrs’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
ERROR: compilation failed for package ‘vctrs’
* removing ‘/Library/Frameworks/R.framework/Versions/4.2/Resources/library/vctrs’
Warning in install.packages :
installation of package ‘vctrs’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/83/1hdhv2r97017s9xxs6yj5hl00000gn/T/Rtmp8tahja/downloaded_packages’
> library(vctrs)
Error in library(vctrs) : there is no package called ‘vctrs’
Any help on how to solve it?

By just dowloading the Command Line Tools package from Apple Developers adapted to the current macOS version solved the problem.

Related

Installing the R package mapview on Ubuntu 20.04

I am trying to install the R package mapview on Ubuntu but I get the error:
ERROR: lazy loading failed for package ‘mapview’
I have tried installing both the CRAN version of mapview and the development version, ie, by:
remotes::install_github("r-spatial/mapview")
In either case, I always get variations of the same message:
> install.packages("mapview")
Installing package into ‘/home/<my user name>/R/x86_64-pc-linux-gnu-library/4.1’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/mapview_2.10.0.tar.gz'
Content type 'application/x-gzip' length 1683417 bytes (1.6 MB)
==================================================
downloaded 1.6 MB
* installing *source* package ‘mapview’ ...
** package ‘mapview’ successfully unpacked and MD5 sums checked
** using staged installation
** R
** data
*** moving datasets to lazyload DB
** inst
** byte-compile and prepare package for lazy loading
corrupted size vs. prev_size
Aborted (core dumped)
ERROR: lazy loading failed for package ‘mapview’
* removing ‘/home/<my username>/R/x86_64-pc-linux-gnu-library/4.1/mapview’
Warning in install.packages :
installation of package ‘mapview’ had non-zero exit status
The downloaded source packages are in
‘/tmp/RtmpKtQmnI/downloaded_packages’
If I try the development version, it asks me to update other packages (eg, raster) but then the same problem occurs for that package.
Other postings have suggested that the error can be fixed by restarting the R session. I have not found this to be the case.
My Session Info is:
R version 4.1.2 (2021-11-01)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.3 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0
locale:
[1] LC_CTYPE=en_NZ.UTF-8 LC_NUMERIC=C LC_TIME=en_NZ.UTF-8
[4] LC_COLLATE=en_NZ.UTF-8 LC_MONETARY=en_NZ.UTF-8 LC_MESSAGES=en_NZ.UTF-8
[7] LC_PAPER=en_NZ.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=en_NZ.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] rstudioapi_0.13 magrittr_2.0.1 usethis_2.1.3 devtools_2.4.3 pkgload_1.2.4
[6] R6_2.5.1 rlang_0.4.12 fastmap_1.1.0 tools_4.1.2 pkgbuild_1.2.1
[11] sessioninfo_1.2.2 cli_3.1.0 withr_2.4.3 ellipsis_0.3.2 remotes_2.4.2
[16] rprojroot_2.0.2 lifecycle_1.0.1 crayon_1.4.2 processx_3.5.2 purrr_0.3.4
[21] callr_3.7.0 fs_1.5.1 ps_1.6.0 testthat_3.1.1 curl_4.3.2
[26] memoise_2.0.1 glue_1.6.0 cachem_1.0.6 compiler_4.1.2 desc_1.4.0
[31] prettyunits_1.1.1
I can't reproduce your error, but you could solve it by installing R with Conda and then the package with https://anaconda.org/conda-forge/r-mapview

Install "gradethis" package for code checking in "learnr"

I am creating the interactive tutorials for R for presentation using "learnr" package. For code checking, I need the package "gradethis". When I try to install this package by
"
remotes::install_github("rstudio-education/gradethis")
"
it gives the error message:
.
.
.
** byte-compile and prepare package for lazy loading
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
namespace ‘learnr’ 0.10.1 is being loaded, but >= 0.10.1.9007 is required
ERROR: lazy loading failed for package ‘gradethis’
─ removing ‘/private/var/folders/r2/3nmkgqc51q54tmhxl00tsk2908fpk9/T/RtmpaPONJB/Rinst15003850258d/gradethis’
-----------------------------------
ERROR: package installation failed
Error: Failed to install 'gradethis' from GitHub:
.
.
.
The error message shows "‘learnr’ 0.10.1 is being loaded, but >= 0.10.1.9007 is required", however on CRAN, 0.10.1 is the latest version:
https://cran.r-project.org/web/packages/learnr/index.html
Can anyone help for this case? Many thanks.
The following show sessionInfo()
> sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.6
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_3.5.1 rjson_0.2.20 plyr_1.8.6
[4] markdown_1.1 htmltools_0.5.1.9000 tools_3.5.1
[7] base64enc_0.1-3 yaml_2.2.1 Rcpp_1.0.6
[10] rmarkdown_2.6 knitr_1.31 xfun_0.20
[13] digest_0.6.27 tutorial_0.4.3 rlang_0.4.10.9000
[16] evaluate_0.14
Since gradethis is still in a developmental/experimental phase, it is currently only available through GitHub at rstudio/gradethis. gradethis currently requires the developmental version of learnr which is also not yet on CRAN.
Installing both packages from their GitHub repositories will likely resolve your issues:
# install.packages("remotes") # require {remotes}
remotes::install_github("rstudio/learnr")
remotes::install_github("rstudio/gradethis")
Edit: The gradethis repository is now hosted under the rstudio GitHub organization.
Reproduced the error (macOS Big Sur 11.1 / Rstudio 1.3.1093 / R version 4.0.3) and solved the issue by uninstalling learnr with remove.packages("learnr") then installing gradethis with dependencies (including the required version of learnr) using remotes::install_github("rstudio-education/gradethis").
If you get a warning that "Skipping install of 'gradethis' from a github remote, the SHA1 has not changed since last install", use the command remotes::install_github("rstudio-education/gradethis", force = TRUE)
Successfully installing the packages requires the ability to compile from source (instructions for macOS Big Sur: https://stackoverflow.com/a/65334247/12957340)

Installing dplyr in R version 3.2.1

Cannot install dplyr in a R 3.2.1 version. I tried everything, I downloaded a previous version of dplyr in the laptop (0.4.2), I tried from other mirrors, but still cannot get it installed. The same with "tidyverse"
When I try it locally it says:
installing source package ‘dplyr’ ...
** package ‘dplyr’ successfully unpacked and MD5 sums checked
** libs sh: make: command not found ERROR: compilation failed for package ‘dplyr’
removing ‘/Library/Frameworks/R.framework/Versions/3.2/Resources/library/dplyr’
restoring previous ‘/Library/Frameworks/R.framework/Versions/3.2/Resources/library/dplyr’
Warning in install.packages : installation of package
‘/Users/x/Desktop/Master/R/dplyr_0.4.0.tar.gz’ had non-zero exit statu
That's the local error.
The online version of installing it says
it cannot be installed
my sessioninfo
R version 3.2.1 (2015-06-18) Platform: x86_64-apple-darwin10.8.0 (64-bit) Running under: OS X 10.8.5 (Mountain Lion) locale: [1] es_ES.UTF-8/es_ES.UTF-8/es_ES.UTF-8/C/es_ES.UTF-8/es_ES.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] remotes_2.0.4 loaded via a namespace (and not attached): [1] httr_1.4.0 R6_2.4.0 tools_3.2.1 RCurl_1.95-4.8 digest_0.6.10 bitops_1.0-6
Thanks!

Unexpected behavior of R when trying to install dplyr

I am trying to update the dplyr package to resolve a problem with rlang, following relevant advice in the web.
First I removed the previous installation of dplyr with the remove.packages() command.
Then I restarted R Studio.
Here is the remaining of the story:
> sessionInfo()
R version 3.4.1 (2017-06-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
[...]
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] RevoUtilsMath_10.0.0 RevoUtils_10.0.5 RevoMods_11.0.0 MicrosoftML_1.5.0 mrsdeploy_1.1.2
[6] RevoScaleR_9.2.1 lattice_0.20-35 rpart_4.1-11
loaded via a namespace (and not attached):
[1] codetools_0.2-15 CompatibilityAPI_1.1.0 foreach_1.4.4 grid_3.4.1 R6_2.2.2
[6] jsonlite_1.5 curl_2.6 iterators_1.0.8 tools_3.4.1 yaml_2.1.14
[11] compiler_3.4.1 mrupdate_1.0.1
> library(dplyr)
Error in library(dplyr) : there is no package called ‘dplyr’
> install.packages('dplyr', dependencies = TRUE)
Installing package into ‘C:/Users/Alienware/Documents/R/win-library/3.4’
(as ‘lib’ is unspecified)
trying URL 'https://mran.microsoft.com/snapshot/2017-09-01/bin/windows/contrib/3.4/dplyr_0.7.2.zip'
Content type 'application/zip' length 2881528 bytes (2.7 MB)
downloaded 2.7 MB
package ‘dplyr’ successfully unpacked and MD5 sums checked
Warning in install.packages :
cannot remove prior installation of package ‘dplyr’
The downloaded binary packages are in
C:\Users\Alienware\AppData\Local\Temp\RtmpucBaSk\downloaded_packages
> library(dplyr)
Error in library(dplyr) : there is no package called ‘dplyr’
Go to your R library path (where your packages are stored):
C:\Users\username\Documents\R\win-library\3.5
You can refer to this guide on how to find your R library path.
Next, simply search for dplyr in your folder and delete it. I find that this manual method works for me as opposed to removing packaging via Rstudio. Hope it helps!

How to fix "Error : object ‘as_tibble’ is not exported by 'namespace:dplyr' ERROR: lazy loading failed for package ‘BLANK’" in R

Whenever I try to install any packages in R I now get this error. This didn't used to happen and is new within the last month and seems to be ubiquitous across all packages I try to install.
I am using R studio but the error occurred when I tried to use just R alone, as well. Currently trying to install rscopus package but the error occurs with most all packages I have tried to install.
Thanks.
Console:
installing the source package ‘rscopus’
trying URL 'https://cran.rstudio.com/src/contrib/rscopus_0.6.3.tar.gz'
Content type 'application/x-gzip' length 40422 bytes (39 KB)
==================================================
downloaded 39 KB
Warning in strptime(xx, f <- "%Y-%m-%d %H:%M:%OS", tz = tz) :
unknown timezone 'zone/tz/2018i.1.0/zoneinfo/America/New_York'
* installing *source* package ‘rscopus’ ...
** package ‘rscopus’ successfully unpacked and MD5 sums checked
** R
** inst
** preparing package for lazy loading
Error : object ‘as_tibble’ is not exported by 'namespace:dplyr'
ERROR: lazy loading failed for package ‘rscopus’
* removing
‘/Library/Frameworks/R.framework/Versions/3.3/Resources/library/rscopus’
Warning in install.packages :
installation of package ‘rscopus’ had non-zero exit status
The downloaded source packages are in ‘/private/var/folders/wz/p_wg38vx11vcp94hhcw5dv_w0000gn/T/RtmpaJeH3b/downloaded_packages’
Sessioninfo()
R version 3.3.2 (2016-10-31)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: macOS 10.14.1
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] tibble_1.3.4 DescTools_0.99.21 dplyr_0.5.0 car_2.1-4
loaded via a namespace (and not attached):
[1] Rcpp_0.12.11 magrittr_1.5 splines_3.3.2 MASS_7.3-45 lattice_0.20-34
[6] R6_2.2.0 rlang_0.1.6 minqa_1.2.4 tools_3.3.2 nnet_7.3-12
[11] parallel_3.3.2 pbkrtest_0.4-6 grid_3.3.2 nlme_3.1-128 mgcv_1.8-15
[16] quantreg_5.29 DBI_0.5-1 MatrixModels_0.4-1 lme4_1.1-12 assertthat_0.1
[21] manipulate_1.0.1 Matrix_1.2-7.1 nloptr_1.0.4 boot_1.3-18 expm_0.999-2
[26] mvtnorm_1.0-6 SparseM_1.74 foreign_0.8-67
For anyone else with similar issues, I updated to the newest version of R and it seemed to solve the problem.
Thinking back to the origin of the problem, it coincided with updated to OS X Mojave.

Resources