Rstudio 1.1.383 R 3.4.2 Ubuntu Linux 14.04 LTS (32 bit) tidyverse 1.1.1.9000
1) When I do: Update PKGS ,
Rstudio offers to update my purrr pkg
from version: 0.2.3 to 0.2.4.
I click button: [Install Updates] --------------------------------------------------
2) Dialog box appears w/ this text:
"One or more of the packages that will be updated by this installation are currently loaded. Restarting R prior to updating these packages is strongly recommended.
RStudio can restart R and then automatically continue the installation after restarting (all work and data will be preserved during the restart).
Do you want to restart R prior to installing?."
I click button: [YES] --------------------------------------------------
3) Resulting output in Rstudio:
install.packages("purrr")
Installing package into ‘/home/ray/R/i686-pc-linux-gnu-library/3.4’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/purrr_0.2.4.tar.gz'
Content type 'application/x-gzip' length 126147 bytes (123 KB)
Can you try updating in a completely fresh R session (i.e. without any packages already loaded)? It looks like having packages already loaded is messing with the installation. (You can refresh your R session in RStudio with CTRL+SHIFT+F10).
Found: a)the reason (for all pkg updates giving "non-zero exit")
and b)a workaround
(maybe you can suggest shorter solution to avoid this problem for future pkg updates).
So, this is the solution...
a)the reason:
I had an initial ".Rprofile" file,
which became effective every time I started Rstudio.
It included this command:
...
.First <- function() {
autoloads <- c("tidyverse","visdat","skimr")
options(defaultPackages = c(getOption("defaultPackages"), autoloads))
}
Somehow, the pkgs autoloaded (above),
interfered with the update of purrr and other pkgs!.
... b) my (long) workaround:
I commented-out the above code
in my .Rprofile file: (w/ CTRL-SHIFT-C)
I then re-started my Rstudio
with the temporary commented-out .Rprofile code,
and clicked [Update] in the Packages pane.
Great!.
ALL pkgs updated fine!.
(no more "non-zero exit" status!). YAY!
Then... I uncommented
the commented .Rprofile code (CTRL-SHIFT-C again),
saved and sourced it,
and restarted Rstudio again.
JIM,
maybe you can suggest a shorter solution
with more practical solution/steps,
to avoid this problem for future pkg updates.
Instead of this LOOOONG sol
every time there is a PKG update...
I'm not sure of any easy way around your exact problem, but it's generally
not a great idea to put code in an Rprofile that loads packages / makes
changes to an otherwise "fresh" R environment. It makes your code less
reproducible and (as you have found) can lead to unexpected errors that are
hard to debug.
Not that I can think of. .Rprofile is the main way to set start-up values; it's not necessarily unsafe, you just need to remember that you have done it if you run in to errors, and before you share code that depeneds on packages loaded in .Rprofile with other people (in case they don't have those packages!).
I'd highly recommend not loading packages in your .Rprofile. As you've seen it can causes problems when updating packages, and in general is likely to lead to less reproducible code.