Loading package by default when starting RStudio

Hi,
Because of some problems with Java and the 'XLConnect' package I uninstalled it. Now, when I start RStudio I get this error.

Loading required package: XLConnect
Error in .requirePackage(package) :
unable to find required package ‘XLConnect’
Además: Warning message:
In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, :
there is no package called ‘XLConnect’

How can I fix this?
Thanks

Either it is being loaded from your .Rprofile file, or because you are loading saved data, which requires it.

Hi,
Thank you. It happens with new session without any loading of saved data. I have try to find this file but I cannot.
This is my system
R version 4.3.2
RStudio 2023.12.0 Build 369

It is in ~/.Rprofile, if you run usethis::edit_r_profile() it should open it in RStudio.

Hi, thanks again,
I found .Rprofile file under
'C:/Users/myuser/Documents/.Rprofile'
However the file is empty. So there is nothing I can change

In that you need to show use your code (if you run anything after starting R), and the complete output from the console window.

I do not run any code. This happens when opening RStudio. This is the Rstudio console output:

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.

Loading required package: XLConnect
Error in .requirePackage(package) :
unable to find required package ‘XLConnect’
In addition: Warning message:
In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, :
there is no package called ‘XLConnect’

Thanks

Do you have an .Rprofile file in the current directory? What is the output of

writeLines(readLines(".Rprofile"))

Do you have an .RData file in the current directory. What is the output of

file.exists(".RData")

What is the output of these?

writeLines(readLines("~/.Rprofile"))
writeLines(readLines(file.path(R.home("etc"), "Rprofile.site")))

Hi Gabor,
Thanks for your help.

writeLines(readLines(".Rprofile"))

No output

file.exists(".RData")

[FALSE]

writeLines(readLines("~/.Rprofile"))
writeLines(readLines(file.path(R.home("etc"), "Rprofile.site")))

Output

# Things you might want to change
# options(papersize="a4")
# options(editor="notepad")
# options(pager="internal")

# set the default help type
# options(help_type="text")
  options(help_type="html")

# set a site library
# .Library.site <- file.path(chartr("\\", "/", R.home()), "site-library")

# set a CRAN mirror
# local({r <- getOption("repos")
#       r["CRAN"] <- "http://my.local.cran"
#       options(repos=r)})

# Give a fortune cookie, but only to interactive sessions
# (This would need the fortunes package to be installed.)
#  if (interactive()) 
#    fortunes::fortune()

Thanks! These look OK.

Another idea. Try running

traceback()

right after the R error happens when opening R, and show us the output.

> traceback()
8: stop(gettextf("unable to find required package %s", sQuote(package)), 
       domain = NA)
7: .requirePackage(package)
6: getClassDef(class1)
5: extends(Class, maybe = FALSE)
4: .extendsForS3(structure("workbook", package = "XLConnect"))
3: inherits(object, "xml_node")
2: .rs.explorer.inspectObject(object, context)
1: .rs.rpc.explorer_begin_inspect("b0bfd6c5682f4facb83b901b033098c0", 
       "Workbook")

Try closing all your RStudio tabs and then restarting. It looks to me like you may have a tab open with an XLConnect object in it (in an Object Explorer/Inspector tab). RStudio is trying to reload the XLConnect package so it can show the object again.

1 Like

Hi Jonathan,
That was the problem. Many thanks!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.