diff -Naur R-2.7.0.orig/src/library/utils/R/packages2.R R-2.7.0/src/library/utils/R/packages2.R
--- R-2.7.0.orig/src/library/utils/R/packages2.R	2008-04-10 04:05:02.000000000 +0200
+++ R-2.7.0/src/library/utils/R/packages2.R	2008-05-25 00:04:25.000000000 +0200
@@ -134,7 +134,29 @@
                 domain = NA, immediate. = TRUE)
         userdir <- unlist(strsplit(Sys.getenv("R_LIBS_USER"),
                                    .Platform$path.sep))[1]
-        if(interactive() && !file.exists(userdir)) {
+        if (file.exists(userdir)) {
+            ## check for writability of userdir by user
+            ok <- file.info(userdir)$isdir & (file.access(userdir, 2) == 0)
+            if(length(userdir) == 1 && .Platform$OS.type == "windows") {
+                ## file.access is unreliable on Windows, especially Vista.
+                ## the only known reliable way is to try it
+                ok <- file.info(userdir)$isdir
+                if(ok) {
+                    fn <- file.path(userdir, "_test_dir_")
+                    unlink(fn, recursive = TRUE) # precaution
+                    res <- try(dir.create(fn, showWarnings = FALSE))
+                    if(inherits(res, "try-error") || !res) ok <- FALSE
+                    else unlink(fn, recursive = TRUE)
+                }
+            }
+            if (ok) {
+                lib <- userdir
+                warning(gettextf("using '%s'", lib),
+                        immediate. = TRUE, domain = NA)
+            }
+            else stop(sQuote(userdir), "\nis not a writable directory, unable to install packages")
+        } else {
+          if(interactive()) {
             msg <- gettext("Would you like to create a personal library\n'%s'\nto install packages into?")
             if(.Platform$OS.type == "windows") {
                 ans <- winDialog("yesno", sprintf(msg, userdir))
@@ -147,7 +169,8 @@
                 stop("unable to create ", sQuote(userdir))
             lib <- userdir
             .libPaths(c(userdir, .libPaths()))
-        } else stop("unable to install packages")
+          } else stop("unable to install packages")
+        }
     }
 
     if(.Platform$OS.type == "windows") {
