Error installing tidyr on Ubuntu 18.04 & R 4.0.2 - r

In trying to install the package tidyverse, I get errors in the installation of dependency tidyr.
Here is the tail of the message I get:
cpp11.cpp:31:100: error: ‘unmove’ is not a member of ‘cpp11’
return cpp11::as_sexp(simplifyPieces(cpp11::unmove(cpp11::as_cpp<cpp11::list>(pieces)), cpp11::unmove(cpp11::as_cpp<int>(p)), cpp11::unmove(cpp11::as_cpp<bool>(fillLeft))));
^~~~~~
cpp11.cpp:31:138: error: ‘unmove’ is not a member of ‘cpp11’
return cpp11::as_sexp(simplifyPieces(cpp11::unmove(cpp11::as_cpp<cpp11::list>(pieces)), cpp11::unmove(cpp11::as_cpp<int>(p)), cpp11::unmove(cpp11::as_cpp<bool>(fillLeft))));
^~~~~~
/usr/lib/R/etc/Makeconf:176: recipe for target 'cpp11.o' failed
make: *** [cpp11.o] Error 1
ERROR: compilation failed for package ‘tidyr’
* removing ‘/home/xxx/yyy/tidyr’
Warning in install.packages :
installation of package ‘tidyr’ had non-zero exit status
To my naive eye, it would seem the issue lies with cpp11. I saw a similar question regarding tidyr installation error due to cpp11 compilation error (R tidyr package installation failed due to cpp11 compilation error (expansion pattern x contains no argument packs)), but it was for a RHEL system.
I have the latest version of gcc/c++ installed on my system (4:7.4.0-1ubuntu2.3). The latest version of system dependencies libcurl4-openssl-dev libssl-dev libxml2-dev are also installed.
Here is the output of sessionInfo():
R version 4.0.2 (2020-06-22)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.5 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1
locale:
[1] LC_CTYPE=en_CA.UTF-8 LC_NUMERIC=C LC_TIME=en_CA.UTF-8 LC_COLLATE=en_CA.UTF-8 LC_MONETARY=en_CA.UTF-8 LC_MESSAGES=en_CA.UTF-8
[7] LC_PAPER=en_CA.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_CA.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.11 magrittr_1.5 usethis_1.6.1 devtools_2.3.1 pkgload_1.1.0 R6_2.4.1 rlang_0.4.7 fansi_0.4.1 tools_4.0.2
[10] pkgbuild_1.1.0 sessioninfo_1.1.1 cli_2.0.2 withr_2.2.0 ellipsis_0.3.1 remotes_2.2.0 assertthat_0.2.1 digest_0.6.25 rprojroot_1.3-2
[19] crayon_1.3.4 processx_3.4.3 callr_3.4.3 fs_1.5.0 ps_1.3.3 curl_4.3 testthat_2.3.2 memoise_1.1.0 glue_1.4.1
[28] compiler_4.0.2 desc_1.2.0 backports_1.1.8 prettyunits_1.1.1

It looks like #hadley released an update to tidyr a few days ago, based on the new cpp11 package: https://github.com/tidyverse/tidyr/releases.
For some reason, this caused tidyr to not build for us.
Our (hopefully temporary!) workaround was like this:
(1) Remove dependency on tidyverse. Instead, explicitly depend on the subpackages( like dplyr/ggplot2/etc. )
(2) Install tidyr in the following way:
packageurl <- "https://cran.r-project.org/src/contrib/Archive/tidyr/tidyr_1.1.0.tar.gz"
install.packages(packageurl, repos=NULL, type="source")

Looks like the following commit is addressing this, though not sure when it will be pushed to CRAN: https://github.com/r-lib/cpp11/commit/779669a4d0b07e9f9d9382114f44e4f6ff68eebb

I found the following here: https://github.com/tidyverse/tidyr/issues/1024
The workaround consists in downgrading cpp11 to version 0.1:
devtools::install_version("cpp11", version = "0.1", repos = "http://cran.us.r-project.org")

Based on the answers from #djacobs7, #mkamenet3, and #Leandro R. M. de Marco, I ended up implementing the following solution, which worked for me.
Removing the cpp11 package, which I had installed from cran.
Re-installing the cpp11 package, but this time from github, as it contains the commit mentioned by #mkamenet3.
devtools::install_github("r-lib/cpp11")
Installing tidyr normally
install.packages("tidyr")

Related

Trouble with downloading certain packages from github in R

I get an error when I try to download and install some packages from github on my Mac, e.g. lubripack. How do I locate what the error actually means? And how to solve it?
I run: install_github("Espanta/lubripack"). I have tried with different libpaths and with force=TRUE.
This is from the console:
checking for file
‘/private/var/folders/nc/vs1bpbqn095bbx84qcwwm4bm0000gn/T/RtmpMn5l2o/remotes8cb7b2460a1/Espanta-lubripack-b1dd9ee/DESCRIPTION’
... OK preparing ‘lubripack’: checking DESCRIPTION meta-information
... OK checking for LF line-endings in source and make files and shell
scripts checking for empty or unneeded directories building
‘lubripack_0.1.tar.gz’ Error: Failed to install 'lubripack' from
GitHub: (converted from warning) line 1 appears to contain an
embedded nul
You may not need to worry about installing the package from github - since the package only contains a single function, I'd simply copy the code for that function and use it (citing the author if/when appropriate).
lubripack <- function(...,silent=FALSE){
#check names and run 'require' function over if the given package is installed
requirePkg<- function(pkg){if(length(setdiff(pkg,rownames(installed.packages())))==0)
require(pkg, quietly = TRUE,character.only = TRUE)
}
# list of packages to install and load
packages <- as.vector(unlist(list(...)))
if(!is.character(packages))stop("No numeric allowed! Input must contain package names to install and load")
if (length(setdiff(packages,rownames(installed.packages()))) > 0 )
install.packages(setdiff(packages,rownames(installed.packages())),
repos = c("https://cran.revolutionanalytics.com/", "http://owi.usgs.gov/R/"))
res<- unlist(sapply(packages, requirePkg))
if(silent == FALSE && !is.null(res)) {cat("\nBellow Packages Successfully Installed:\n\n")
print(res)
}
}
It works for me even on R 4.0.2
lubripack(list("dplyr"))
Bellow Packages Successfully Installed:
dplyr
TRUE
And for reference
sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS 10.16
Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
locale:
[1] en_AU.UTF-8/en_AU.UTF-8/en_AU.UTF-8/C/en_AU.UTF-8/en_AU.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] dplyr_1.0.0 gtools_3.8.2
loaded via a namespace (and not attached):
[1] crayon_1.3.4 R6_2.4.1 lifecycle_0.2.0 magrittr_1.5 pillar_1.4.6 rlang_0.4.7 rstudioapi_0.11 vctrs_0.3.2
[9] generics_0.0.2 ellipsis_0.3.1 tools_4.0.2 glue_1.4.1 purrr_0.3.4 compiler_4.0.2 pkgconfig_2.0.3 tidyselect_1.1.0
[17] tibble_3.0.3
Try this
First run
install.packages("remotes")
once done
Run this : -
remotes::install_github("Espanta/lubripack")
Ignore the warning
I am able to load the library
I am not sure if this library is up to date like Dirk Eddelbuettel mentioned
But its loading

CURL_OPENSSL_3 problem while installing biomaRt R package on Ubuntu 20.04

Problem
I am trying to install biomaRt R package, but I have been experiencing problems. I have also noticed that the same problem also occurs with some other packages like twitteR. It seems like it is a problem related to curl.
When I run the following installation command below:
if (!requireNamespace("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("biomaRt")
I receive the following error message:
Bioconductor version 3.10 (BiocManager 1.30.10), R 3.6.3 (2020-02-29)
Installing package(s) 'biomaRt'
also installing the dependency ‘BiocFileCache’
trying URL 'https://bioconductor.org/packages/3.10/bioc/src/contrib/BiocFileCache_1.10.2.tar.gz'
Content type 'application/x-gzip' length 288347 bytes (281 KB)
==================================================
downloaded 281 KB
trying URL 'https://bioconductor.org/packages/3.10/bioc/src/contrib/biomaRt_2.42.1.tar.gz'
Content type 'application/x-gzip' length 431995 bytes (421 KB)
==================================================
downloaded 421 KB
* installing *source* package ‘BiocFileCache’ ...
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/usr/local/lib/R/site-library/curl/libs/curl.so':
/usr/local/lib/R/site-library/curl/libs/curl.so: undefined symbol: curl_easy_strerror, version CURL_OPENSSL_3
Calls: <Anonymous> ... asNamespace -> loadNamespace -> library.dynam -> dyn.load
Execution halted
Question
Have you experienced something similar? If so, how did you solve it?
Attempts to solve
Tried to install RCurl package as mentioned here, but it did not help.
Tried installing libcurl3 as mentioned here. However, it breaks down R installation.
Tried re-installing R.
And none of above worked for me.
R session info
> sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.1 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_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] crayon_1.3.4 dplyr_1.0.2 grid_3.6.3 R6_2.4.1 gtable_0.3.0 lifecycle_0.2.0
[7] magrittr_1.5 scales_1.1.1 ggplot2_3.3.2 pillar_1.4.6 rlang_0.4.7 rstudioapi_0.11
[13] vctrs_0.3.4 generics_0.0.2 ellipsis_0.3.1 tools_3.6.3 glue_1.4.2 munsell_0.5.0
[19] purrr_0.3.4 compiler_3.6.3 colorspace_1.4-1 pkgconfig_2.0.3 BiocManager_1.30.10 tidyselect_1.1.0
[25] tibble_3.0.3
While I was writing this thread, I came across a simple solution.
Basically uninstalling and installing R curl package helped.
remove.packages("curl")
install.packages("curl")

GenomicRanges Error loading DESeq2 library on R

I tried to loading DESeq2 on R:
library(DESeq2)
The Error showed is:
Loading required package: GenomicRanges
Error: package or namespace load failed for ‘GenomicRanges’ in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]):
object 'vI' not found
Error: package ‘GenomicRanges’ could not be loaded
> sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Sierra 10.12.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.6/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] parallel stats4 stats graphics grDevices utils datasets
[8] methods base
other attached packages:
[1] GenomeInfoDb_1.22.1 IRanges_2.21.8 S4Vectors_0.25.15
[4] BiocGenerics_0.32.0
loaded via a namespace (and not attached):
[1] rstudioapi_0.11 zlibbioc_1.32.0 R6_2.4.1
[4] fansi_0.4.1 tools_3.6.3 pkgbuild_1.0.6
[7] cli_2.0.2 withr_2.1.2 remotes_2.1.1
[10] assertthat_0.2.1 rprojroot_1.3-2 crayon_1.3.4
[13] processx_3.4.2 GenomeInfoDbData_1.2.2 BiocManager_1.30.10
[16] callr_3.4.3 bitops_1.0-6 ps_1.3.2
[19] RCurl_1.98-1.1 curl_4.3 glue_1.4.0
[22] compiler_3.6.3 backports_1.1.6 prettyunits_1.1.1
I blocked since 2 days. All the problem start for "S4Vectors" package. I solved it. I update the R. I donwloaded and manually put in the library r folder the "XVector" version ‘0.27.2’ as required from GenomicRanges.
I need to use DESeq2 to normalize my cont data. I open to use also something different from r
At the end, I fixed the problem uninstalled and re-installed all the R library from my PC keeping the same OS and R version. I continue to ignore the real identity of the problem.
I resolved this problem simply by removing the "GenomicRanges" and "IRange" packages and installing "GenomicRanges" again.
To remove these packages I used .libPaths() to find the library path and removed GenomicRanges" and "IRange" folders.

R package not available in batch mode

I have been running a bash script (under Ubuntu) that calls and runs some R scripts to plot some maps with ggplot2. As it is a production system I don't update any new R or package releases. But recently I tried to install plotly with an error message output.
Now, when trying to run the script (calling a php webpage trhough a browser; that was running fine for a lot of time) an error with crayon package halts and exits the script without plotting the maps.
'/usr/lib/R/bin/R --slave --no-restore --no-save --no-restore --file=./RAMS-mapa-onades-zones-manual.R'
Loading required package: sp
Loading required package: methods
Checking rgeos availability: TRUE
Error : .onLoad failed in loadNamespace() for 'pillar', details:
call: loadNamespace(name)
error: there is no package called 'crayon'
Error: package or namespace load failed for 'ggplot2'
Execution halted
But if I run from a terminal or with RStudio server crayon package is loaded, ggplot2 is also properly loaded, and the maps are produced.
crayon package (located at /home/meteo/R/i686-pc-linux-gnu-library/3.1) called as
library("crayon", lib.loc= c("/home/meteo/R/i686-pc-linux-gnu-library/3.1", "/usr/local/lib/R/site-library", "/usr/lib/R/library"))
R session info on Rstudio Server:
> sessionInfo()
R version 3.2.2 (2015-08-14)
Platform: i686-pc-linux-gnu (32-bit)
Running under: Ubuntu precise (12.04.5 LTS)
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=C LC_COLLATE=C LC_MONETARY=C LC_MESSAGES=C
[7] LC_PAPER=C LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=C LC_IDENTIFICATION=C
attached base packages:
[1] grid stats graphics grDevices utils datasets methods base
other attached packages:
[1] crayon_1.3.4 rgdal_0.9-1 rgeos_0.3-8 raster_2.3-24 gpclib_1.5-5 mapproj_1.2-2 maps_2.3-9
[8] stringr_0.6.2 plyr_1.8.1 ggplot2_3.2.0 maptools_0.8-34 sp_1.2-3
loaded via a namespace (and not attached):
[1] Rcpp_1.0.1 magrittr_1.5 tidyselect_0.2.5 munsell_0.5.0 colorspace_1.2-4 lattice_0.20-33 R6_2.4.0
[8] rlang_0.3.4 dplyr_0.8.1 tools_3.2.2 gtable_0.1.2 withr_2.1.2 digest_0.6.8 lazyeval_0.2.2
[15] assertthat_0.2.1 tibble_2.1.3 purrr_0.3.2 glue_1.3.1 labeling_0.3 pillar_1.4.1 scales_1.0.0
[22] foreign_0.8-66 pkgconfig_2.0.2
Maybe there is a version conflict? How do I check?
what version of R is in /usr/lib/R/bin/R? Basically it appears you are in a slight "dependency hell" I would run /usr/lib/R/bin/R and check to see if crayon is installed there. #Alexis is correct though, it is not wise to mix versions like that. Let R handle library location unless you are trying to separate packages. Check the libraries for 3.2.2 and see if crayon is installed. you may have switched your R version since plotly depends on R >=3.2.0 https://cran.r-project.org/web/packages/plotly/
I think the easy fix would be to correct your .libpaths() i.e not call the 3.1 library and install the correct version of the packages you need.
OR
switch from R 3.2 back to R 3.1

Issues installing quantstrat for version 3.4.2

I am trying to install the quantstrat package in R. I already installed the other packages necessary for quantstrat, below is my session info.
sessionInfo()
R version 3.4.2 (2017-09-28)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=Portuguese_Brazil.1252 LC_CTYPE=Portuguese_Brazil.1252 LC_MONETARY=Portuguese_Brazil.1252 LC_NUMERIC=C
[5] LC_TIME=Portuguese_Brazil.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] blotter_0.12.4 PerformanceAnalytics_1.5.1 FinancialInstrument_1.2.0 foreach_1.4.3 quantmod_0.4-11
[6] TTR_0.23-2 devtools_1.13.4 xts_0.10-0 zoo_1.8-0 lubridate_1.7.1
loaded via a namespace (and not attached):
[1] Rcpp_0.12.13 rstudioapi_0.7 knitr_1.17 magrittr_1.5 lattice_0.20-35 R6_2.2.2 quadprog_1.5-5 stringr_1.2.0
[9] httr_1.3.1 tools_3.4.2 grid_3.4.2 git2r_0.19.0 withr_2.1.0 iterators_1.0.8 yaml_2.1.14 digest_0.6.12
[17] codetools_0.2-15 curl_3.0 memoise_1.1.0 stringi_1.1.5 compiler_3.4.2 boot_1.3-20
when I run the install packages this is what I get:
install.packages("quantstrat", repos="https://github.com/braverock/quantstrat.git")
Installing package into ‘C:/Users/augus/Documents/R/win-library/3.4’
(as ‘lib’ is unspecified)
Warning in install.packages :
unable to access index for repository https://github.com/braverock/quantstrat.git/src/contrib:
cannot open URL 'https://github.com/braverock/quantstrat.git/src/contrib/PACKAGES'
Warning in install.packages :
package ‘quantstrat’ is not available (for R version 3.4.2)
Warning in install.packages :
unable to access index for repository https://github.com/braverock/quantstrat.git/bin/windows/contrib/3.4:
cannot open URL 'https://github.com/braverock/quantstrat.git/bin/windows/contrib/3.4/PACKAGES'
I have also tried to download a previous version and install it, but with no success, I got it from the followin link:
http://download.r-forge.r-project.org/bin/windows/contrib/3.2/quantstrat_0.9.1739.zip
install.packages("C:/Users/augus/Dropbox/Trading/R/quantstrat_0.9.17392.zip", repos = NULL)
Installing package into ‘C:/Users/augus/Documents/R/win-library/3.4’
(as ‘lib’ is unspecified)
Warning in install.packages :
cannot open compressed file 'quantstrat/DESCRIPTION', probable reason 'No such file or directory'
Error in install.packages : cannot open the connection
Does someone know what I am doing wrong?
Thanks
Augusto
As noted in the comments above, for completeness here is an answer.
The most straightforward way to install the latest version of quantstrat is via github with devtools (the version of quantstrat on R-forge is now out of date):
library(devtools)
install_github("braverock/quantstrat")

Resources