Home > Software engineering >  Why does R show a package error immediately when I open the program?
Why does R show a package error immediately when I open the program?

Time:06-07

When I open R, before I type in any commands, the console immediately shows an error indicating that the curatedMetagenomicData package is not installed.

R version 4.2.0 (2022-04-22 ucrt) -- "Vigorous Calisthenics"
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

Error in library("curatedMetagenomicData") : 
  there is no package called ‘curatedMetagenomicData’

curatedMetagenomicData is a Bioconductor package I used a few years ago and which I must have removed at some point. When I try to reinstall it, the installation fails, seemingly because it isn't installed already?

> BiocManager::install("curatedMetagenomicData")
'getOption("repos")' replaces Bioconductor standard repositories, see '?repositories' for details

replacement repositories:
    CRAN: https://cran.rstudio.com/

Bioconductor version 3.15 (BiocManager 1.30.18), R 4.2.0 (2022-04-22 ucrt)
Installing package(s) 'curatedMetagenomicData'
installing the source package ‘curatedMetagenomicData’

trying URL 'https://bioconductor.org/packages/3.15/data/experiment/src/contrib/curatedMetagenomicData_3.4.2.tar.gz'
Content type 'application/x-gzip' length 1855762 bytes (1.8 MB)
downloaded 1.8 MB

Error in library("curatedMetagenomicData") : 
  there is no package called 'curatedMetagenomicData'
Execution halted

The downloaded source packages are in
    ‘C:\Users\jpennycook\AppData\Local\Temp\RtmpqcBkUu\downloaded_packages’
Warning message:
In install.packages(...) :
  installation of package ‘curatedMetagenomicData’ had non-zero exit status

This seems to cause problems in unexpected places, such as when I try to knit an R Markdown document (completely unrelated to curatedMetagenomicData), which fails with the following message in the 'Render' window of RStudio.

Error in library("curatedMetagenomicData") : 
  there is no package called 'curatedMetagenomicData'
Execution halted

I've tried removing my R and RStudio installations as thoroughly as I can, then re-installing, but the issue persists. I can't understand what is prompting R to check if this package is installed. Can anyone help me understand this? I don't currently need to use the package in question, but the errors are becoming a pain.

EDIT:

This issue is also cropping up when I try to install any package from source (whether it's curatedMetagenomicData or another, such as dbplyr). In each case, the problem is apparently that curatedMetagenomicData is not already installed.

> install.packages("C:/Users/jpennycook/AppData/Local/Temp/RtmpqcBkUu/downloaded_packages/curatedMetagenomicData_3.4.2.tar.gz",
                   repos = NULL, type = "source")
Installing package into ‘C:/Users/jpennycook/Documents/myRlibs’
(as ‘lib’ is unspecified)
Error in library("curatedMetagenomicData") : 
  there is no package called 'curatedMetagenomicData'
Execution halted
Warning in install.packages :
  installation of package ‘C:/Users/jpennycook/AppData/Local/Temp/RtmpqcBkUu/downloaded_packages/curatedMetagenomicData_3.4.2.tar.gz’ had non-zero exit status

> install.packages("C:/Users/jpennycook/AppData/Local/Temp/RtmpqcBkUu/downloaded_packages/dbplyr_2.2.0.tar.gz",
                   repos = NULL, type = "source")
Installing package into ‘C:/Users/jpennycook/Documents/myRlibs’
(as ‘lib’ is unspecified)
Error in library("curatedMetagenomicData") : 
  there is no package called 'curatedMetagenomicData'
Execution halted
Warning in install.packages :
  installation of package ‘C:/Users/jpennycook/AppData/Local/Temp/RtmpqcBkUu/downloaded_packages/dbplyr_2.2.0.tar.gz’ had non-zero exit status

CodePudding user response:

Based on responses in the comments, I'll promote my comment to an answer.

Two possible causes of this problem are

  • you have a .Rprofile file in your home directory that is trying to load packages
  • you have a .RData file in your current working directory that is being auto-loaded; it has an object in it that will trigger the loading of this package

Note that in either case files whose names start with a . are usually invisible by default in file managers/file listings, so you may have to search for them carefully

file.exists(".RData") and file.exists("~/.Rprofile") will tell you whether these files exist; you could diagnose the problem by moving/renaming each one temporarily.

  • Related