Error with C Stack Usage when installing packages - r

I haven't touched R in a while, and just tried running some old Bioconductor code on my new Mac (M1, 2020, running OS Monterey 12.2.1).
I am able to run the beginning of my script (where I install packages) seemingly without issue:
library("knitr")
.cran_packages <- c("ggplot2", "gridExtra")
.bioc_packages <- c("dada2", "phyloseq", "DECIPHER", "phangorn", "msa")
.inst <- .cran_packages %in% installed.packages()
if(any(!.inst)) {
install.packages(.cran_packages[!.inst])
}
.inst <- .bioc_packages %in% installed.packages()
if(any(!.inst)) {
BiocManager::install(.bioc_packages[!.inst])
}
However, when I go to actually load the packages, like so:
sapply(c(.cran_packages, .bioc_packages), require, character.only = TRUE)
many of the bioconductor packages fail to load, with this readout:
Loading required package: dada2
Error: package or namespace load failed for ‘dada2’ in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]):
there is no package called ‘GenomeInfoDbData’
Loading required package: phyloseq
Error: package or namespace load failed for ‘phyloseq’ in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]):
there is no package called ‘GenomeInfoDbData’
Loading required package: DECIPHER
Loading required package: Biostrings
Failed with error: ‘package ‘S4Vectors’ required by ‘Biostrings’ could not be found’
In addition: Warning message:
In read.dcf(file.path(p, "DESCRIPTION"), c("Package", "Version")) :
cannot open compressed file '/Library/Frameworks/R.framework/Versions/4.1/Resources/library/S4Vectors/DESCRIPTION', probable reason 'No such file or directory'
Loading required package: msa
Loading required package: Biostrings
Failed with error: ‘package ‘S4Vectors’ required by ‘Biostrings’ could not be found’
In addition: Warning message:
In read.dcf(file.path(p, "DESCRIPTION"), c("Package", "Version")) :
cannot open compressed file '/Library/Frameworks/R.framework/Versions/4.1/Resources/library/S4Vectors/DESCRIPTION', probable reason 'No such file or directory'
ggplot2 gridExtra dada2 phyloseq DECIPHER phangorn msa
TRUE TRUE FALSE FALSE FALSE TRUE FALSE
Based on this result, I have tried re-installing ‘GenomeInfoDbData’ and ‘S4Vectors’ separately. It looks like the issue with installing ‘GenomeInfoDbData’ is the version of ‘S4Vectors’. When I choose to skip updating S4Vectors, I get this error message:
> BiocManager::install("GenomeInfoDbData")
'getOption("repos")' replaces Bioconductor standard repositories, see '?repositories' for
details
replacement repositories:
CRAN: https://cran.rstudio.com/
Bioconductor version 3.14 (BiocManager 1.30.16), R 4.1.3 (2022-03-10)
Installing package(s) 'GenomeInfoDbData'
installing the source package ‘GenomeInfoDbData’
trying URL 'https://bioconductor.org/packages/3.14/data/annotation/src/contrib/GenomeInfoDbData_1.2.7.tar.gz'
Content type 'application/x-gzip' length 11193674 bytes (10.7 MB)
==================================================
downloaded 10.7 MB
Error: C stack usage 7953728 is too close to the limit
Execution halted
The downloaded source packages are in
‘/private/var/folders/84/4fxygqsd07zcn8kzy9yh8t2c0000gn/T/RtmppKV5Cc/downloaded_packages’
Old packages: 'S4Vectors'
Update all/some/none? [a/s/n]:
n
Warning message:
In .inet_warning(msg) :
installation of package ‘GenomeInfoDbData’ had non-zero exit status
and when I choose to proceed with updating S4Vectors (from binary), I get a similar error:
Old packages: 'S4Vectors'
Update all/some/none? [a/s/n]:
a
There is a binary version available but the source version is later:
binary source needs_compilation
S4Vectors 0.32.3 0.32.4 TRUE
Do you want to install from sources the package which needs compilation? (Yes/no/cancel) n
trying URL 'https://bioconductor.org/packages/3.14/bioc/bin/macosx/contrib/4.1/S4Vectors_0.32.3.tgz'
Content type 'application/x-gzip' length 2099211 bytes (2.0 MB)
==================================================
downloaded 2.0 MB
The downloaded binary packages are in
/var/folders/84/4fxygqsd07zcn8kzy9yh8t2c0000gn/T//RtmppKV5Cc/downloaded_packages
Warning message:
In .inet_warning(msg) :
installation of package ‘GenomeInfoDbData’ had non-zero exit status
This also, for some reason seems to involve an issue with my C-stack usage, which I cannot get to the bottom of. I have tried un-installing and re-installing R and R studio, trying both the version for the M1 macs and the Intel macs. Here's my system info at the moment:
R version 4.1.3 (2022-03-10)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Monterey 12.2.1

Related

How to get out of the R dependency hell?

I have very weird dependency error on my R/R-studio environment after I updated the R-studio version from v1.2.5042 to the latest (v2022.02.2+485);
The problem is that when I try to load a package, some packages logs an error, as follows.
> library(plotly)
Error: package or namespace load failed for ‘plotly’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
namespace ‘htmlwidgets’ 1.5.1 is already loaded, but >= 1.5.2.9001 is required
In addition: Warning message:
package ‘plotly’ was built under R version 4.0.5
Umm, very weird. Because before I updated the R studio version at least for the plotly package, the importing command never logged an error similar to the above. I'm very confused.
(btw I updated the R studio version because 1. The old version was 2020's one, very old; 2. The plotly package didn't work well, for example it makes R-studio CPU 100% on the PC;)
So, I googled and found an SO post that mentions to the error, namespace xx is already loaded, but >= xx is required:
R install package loaded namespace - Stack Overflow
The answers say in this case I just need to re-install the error-mentioned package and reload it; So I did:
> install.packages("htmlwidgets")
Error in install.packages : Updating loaded packages
> install.packages("htmlwidgets")
WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:
https://cran.rstudio.com/bin/windows/Rtools/
Installing package into ‘C:/_documents/R/win-library/4.0’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.0/htmlwidgets_1.5.4.zip'
Content type 'application/zip' length 905152 bytes (883 KB)
downloaded 883 KB
package ‘htmlwidgets’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\user\AppData\Local\Temp\RtmpeCeZz2\downloaded_packages
Then
> library(htmlwidgets)
Warning message:
package ‘htmlwidgets’ was built under R version 4.0.5
And re-try to the command:
> library(plotly)
Error: package or namespace load failed for ‘plotly’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
namespace ‘rlang’ 0.4.6 is already loaded, but >= 0.4.10 is required
In addition: Warning message:
package ‘plotly’ was built under R version 4.0.5
Wow, a new package name pops up, ‘rlang’. This isn't right.
Anyways I tried to deal with the ‘rlang’ this time:
> install.packages("rlang")
Error in install.packages : Updating loaded packages
> install.packages("rlang")
WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:
https://cran.rstudio.com/bin/windows/Rtools/
Installing package into ‘C:/_documents/R/win-library/4.0’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.0/rlang_1.0.2.zip'
Content type 'application/zip' length 1718545 bytes (1.6 MB)
downloaded 1.6 MB
package ‘rlang’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\user\AppData\Local\Temp\RtmpeCeZz2\downloaded_packages
Then:
> library(rlang)
Error in value[[3L]](cond) :
Package ‘rlang’ version 0.4.6 cannot be unloaded:
Error in unloadNamespace(package) : namespace ‘rlang’ is imported by ‘htmltools’, ‘ellipsis’, ‘tidyr’, ‘purrr’, ‘ggplot2’, ‘tidyselect’, ‘vctrs’, ‘dplyr’, ‘tibble’, ‘lifecycle’, ‘pillar’ so cannot be unloaded
In addition: Warning message:
package ‘rlang’ was built under R version 4.0.5
Woah, I can't even load the dependency package this time. I'm sure something isn't right in my R and/or R-studio.
What's happening, and how can I solve this issue? I mean when simply updating R-studio and restarting doesn' work, what can I do? Thanks.
R.version:
> R.version
_
platform x86_64-w64-mingw32
arch x86_64
os mingw32
system x86_64, mingw32
status
major 4
minor 0.0
year 2020
month 04
day 24
svn rev 78286
language R
version.string R version 4.0.0 (2020-04-24)
nickname Arbor Day

Install/Compiling Errors with R Packages: tidyverse and caret

I recently had to install RStudio and the R language onto a new Macbook. It seemed to install the packages normally but when I started run some newly written code, the console would not execute tidyverse and caret even though it said it was downloaded. This is what shows up in the console and it's the same messages for both caret and tidyverse:
> install.packages("tidyverse")
trying URL 'https://cran.rstudio.com/bin/macosx/contrib/4.1/tidyverse_1.3.1.tgz'
Content type 'application/x-gzip' length 421072 bytes (411 KB)
==================================================
downloaded 411 KB
The downloaded binary packages are in
/var/folders/pl/w9k_0l4d4snfgcv53rp2t_4m0000gn/T//RtmpWScbjK/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 ‘Rcpp’
I even tried to install it on just R and not RStudio too and This is the message that comes up for both tidyverse and caret when I try to install Rcpp both ways on just R and RStudio:
> install.packages("Rcpp")
There is a binary version available but the source version is later:
binary source needs_compilation
Rcpp 1.0.8.2 1.0.8.3 TRUE
Do you want to install from sources the package which needs compilation? (Yes/no/cancel) yes
installing the source package ‘Rcpp’
trying URL 'https://cloud.r-project.org/src/contrib/Rcpp_1.0.8.3.tar.gz'
Content type 'application/x-gzip' length 3086192 bytes (2.9 MB)
==================================================
downloaded 2.9 MB
* installing *source* package ‘Rcpp’ ...
** package ‘Rcpp’ 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 ‘Rcpp’
* removing ‘/Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp’
The downloaded source packages are in
‘/private/var/folders/pl/w9k_0l4d4snfgcv53rp2t_4m0000gn/T/Rtmp53AysU/downloaded_packages’
Warning message:
In install.packages("Rcpp") :
installation of package ‘Rcpp’ had non-zero exit status
I'm not sure what's going wrong and I'm not seeing any solution on here or other sites that are working for me, I'd appreciate any help with this since I use R alot. If more info is needed please comment, thanks.
It could be that you need to reinstall the rlang package. You can use this code to reinstall this package:
remove.packages("rlang")
install.packages("rlang")
After that you can load the packages tidyverse and caret again:
library(tidyverse)
library(caret)
Check this question for more info: Error: package or namespace load failed for ‘tidyverse’ in loadNamespace

Is it possible to use package semPlot with R 3.6.2?

I upgraded R to version 3.6.2 and have discovered that package semPlot will not work. It installs without any problems, but when I try to load it I get the message,
Error: package or namespace load failed for ‘semPlot’ in
loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck =
vI[[j]]): there is no package called ‘ggm’
I then tried to install ggm but get the following warning and error:
Warning in install.packages : dependency ‘graph’ is not available
There is a binary version available but the source version is
later:
binary source needs_compilation ggm 2.3 2.5 FALSE installing the source package ‘ggm’ trying URL
'https://cran.rstudio.com/src/contrib/ggm_2.5.tar.gz' Content type
'application/x-gzip' length 109414 bytes (106 KB) downloaded 106 KB
ERROR: dependency ‘graph’ is not available for package ‘ggm’ removing
‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/ggm’
Warning in install.packages : installation of package ‘ggm’ had
non-zero exit status"
I then tried to install graph, but it says:
package ‘graph’ is not available (for R version 3.6.2).
I wondered if anyone else had experienced this problem, and had any solutions so I can load semPlot with R 3.6.2?
Many thanks.
I also have R 3.6.2 and get all errors you get. But when I try to install the semPlot package from GitHub, it works fine, as follows:
install.packages('devtools')
library(devtools)
install_github('SachaEpskamp/semPlot', dependencies = T)
library(semPlot)
Please not that I tried the cran/semPlot repository but didn't work for me, whereas SachaEpskamp/semPlot does.
Hope you get it working.

Can't install caret package in R

I have tried multiple ways to install the caret package in R.
The error message that I receive is as follows:
Error: package or namespace load failed for ‘caret’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
there is no package called ‘dimRed’
When I try to install dimRed, I get the following message:
Installing package into ‘C:/Users/Thomas/Documents/R/win-library/3.4’
(as ‘lib’ is unspecified)
Warning in install.packages :
dependency ‘Biobase’ is not available
There is a binary version available but the source version is later:
binary source needs_compilation
dimRed 0.1.0 0.2.1 FALSE
installing the source package ‘dimRed’
trying URL 'https://cran.rstudio.com/src/contrib/dimRed_0.2.1.tar.gz'
Content type 'application/x-gzip' length 363025 bytes (354 KB)
downloaded 354 KB
ERROR: dependency 'Biobase' is not available for package 'dimRed'
* removing 'C:/Users/Thomas/Documents/R/win-library/3.4/dimRed'
In R CMD INSTALL
Warning in install.packages :
running command '"C:/PROGRA~1/R/R-34~1.4/bin/x64/R" CMD INSTALL -l "C:\Users\Thomas\Documents\R\win-library\3.4" C:\Users\Thomas\AppData\Local\Temp\RtmpqKhsKn/downloaded_packages/dimRed_0.2.1.tar.gz' had status 1
Warning in install.packages :
installation of package ‘dimRed’ had non-zero exit status
The downloaded source packages are in
‘C:\Users\Thomas\AppData\Local\Temp\RtmpqKhsKn\downloaded_packages’
Per previous posts, I have updated RStudio. I have attempted an install from install_url.
Any suggestions are welcome.
I was able to figure this out.
Simply typing install.packages won't work. In order to install Biobase, you have to run the following code in R console:
if (!requireNamespace("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("Biobase", version = "3.8")
More info: https://bioconductor.org/packages/release/bioc/html/Biobase.html
Once this step is done, I installed caret again using
install.packages("caret",dependencies = T)
And then it worked.
Warning ...
install.packages("BiocManager")
This only works if your R version is >= 3.5.0
for info I've the same problem under a Centos and a Windows.
issue solved on the windows with 3.5.1 R version. Not yet solved on the centOS (3.4.2)

unable to install packages("caret") completely in R version 3.2.3

> require("caret")
Loading required package: caret
Loading required package: lattice
Loading required package: ggplot2
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
there is no package called ‘pbkrtest’
So I found that there is lack of "pbkrtest" then I tried to reinstall it.
> install.packages("pbkrtest")
Installing package into ‘C:/Users/ADMIN/Documents/R/win-library/3.2’
(as ‘lib’ is unspecified)
There is a binary version available but the source version is
later:
binary source needs_compilation
pbkrtest 0.4-2 0.4-3 FALSE
installing the source package ‘pbkrtest’
trying URL 'https://rweb.crmda.ku.edu/cran/src/contrib/pbkrtest_0.4- 3.tar.gz'
Content type 'application/x-gzip' length 164415 bytes (160 KB)
downloaded 160 KB
* installing *source* package 'pbkrtest' ...
** package 'pbkrtest' successfully unpacked and MD5 sums checked
** R
** data
** inst
** preparing package for lazy loading
Warning: replacing previous import by 'stats::sigma' when loading 'pbkrtest'
Error : object 'sigma' is not exported by 'namespace:stats'
ERROR: lazy loading failed for package 'pbkrtest'
* removing 'C:/Users/ADMIN/Documents/R/win-library/3.2/pbkrtest'
The downloaded source packages are in
‘C:\Users\ADMIN\AppData\Local\Temp\Rtmpk7mJT0\downloaded_packages’
Warning messages:
1: running command '"D:/R-3.2.3/bin/x64/R" CMD INSTALL -l
"C:\Users\ADMIN\Documents\R\win-library\3.2"
C:\Users\ADMIN\AppData\Local\Temp\Rtmpk7mJT0/downloaded_packages/pbkrtest_0.4- 3.tar.gz' had status 1
2: In install.packages("pbkrtest") :
installation of package ‘pbkrtest’ had non-zero exit status
It seems like that the installation keeps failing.
As a result, I couldn't use other code using caret packages.
I faced this problem as well on Windows 7. I did following steps in the sequence and it worked.
a) Make sure your R version is updated latest R release 3.2.3
b) The default sources seems to be installing Unix version. So I manually downloaded https://cran.r-project.org/web/packages/pbkrtest/index.html for windows
c) Use manually install function from R menu to install the package.
Cheers,
Ratan
Check version of R by typing version in your console.
If version is not "version.string R version 3.3.2" or later then
Install new version of R from https://cran.r-project.org/bin/windows/base/
Update R version using Tools => Global Options in RStudio.
install package using "install.packages("caret")" in your console.
do require(caret).
test using ?createDataPartition.

Resources