Search code examples
rrstudioxlconnectrdata

How can I stop a package from loading on startup in Rstudio


I have an Rstudio project that I've been working on. Since I last updated Rstudio to 1.0.143 - Mac OS X 10.6+ (64-bit) the project fails to start up. I think it might be linked to a package that was automatically loading on start-up and for whatever reason has not decided to stop working with R/Rstudio. XLConnect...

I've tried removing .RData, .Rhistory and .Rproj.user from the directory. Only removing .RData worked and Rstudio started up without issues. I don't seem to have any .RProfile files in the directory, my home directory or a site-wide file either.

Right now I can't even open the Rstudio session because it crashes with an error

R encountered a fatal error. The session was terminated.

I can open other Rstudio sessions without a problem.

When I open a separate R session (no R studio) and try to

load('path/to/.RData')

I get the following error message:

* caught segfault * address 0x18, cause 'memory not mapped'

Traceback: 1: dyn.load(file, DLLpath = DLLpath, ...)

2: library.dynam(lib, package, package.lib)

3: loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]])

4: asNamespace(ns)

5: namespaceImportFrom(ns, loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]), i[[2L]], from = package)

6: loadNamespace(name)

7: doTryCatch(return(expr), name, parentenv, handler)

8: tryCatchOne(expr, names, parentenv, handlers[[1L]])

9: tryCatchList(expr, classes, parentenv, handlers)

10: tryCatch(loadNamespace(name), error = function(e) { warning(gettextf("namespace %s is not available and has been

replaced\nby .GlobalEnv when processing object %s", sQuote(name)[1L], sQuote(where)), domain = NA, call. = >FALSE, immediate. = TRUE) .GlobalEnv})

11: ..getNamespace(c("openxlsx", "4.0.17"), "uwc.sel.book")

12: load("./Dropbox/OxfordTT2017/DNAextraction_26052017/ColWork2017/Fielddata_04052016/.RData")

Possible actions:

1: abort (with core dump, if enabled)

2: normal R exit

3: exit R without saving workspace

4: exit R saving workspace

So I'm looking for a way to stop the Rstudio session from loading the packages on startup (I'm not sure why it does this in the first place as I don't remember setting any kind of RProfile..).


Solution

  • So this is what I did to solve the problem:

    Everything below is at the directory which containes the *.RProj file.

    First, I 'hid' the .RData file by running this in the terminal.

    mv .RData ./.RData_old
    

    Next, I ran this in an R session (not Rstudio):

    remove.packages('XLConnect', 'XLConnectJars')
    

    Then I closed the R session and opened the Rstudio project to make sure it would open fine without the RData file.

    After that I got my RData file back

    mv .RData_old ./.RData
    

    Finally I opened the project file again and presto!

    It complains about packages not installed but at least I know which packages are required. Moreover, my data and results aren't lost.