From georgi.boshnakov at manchester.ac.uk  Thu Feb 18 11:43:11 2010
From: georgi.boshnakov at manchester.ac.uk (Georgi Boshnakov)
Date: Thu, 18 Feb 2010 10:43:11 +0000
Subject: [Rd] install.packages, normalizePath, file permissions
Message-ID: <20100218104311.3130687nyivhp03j@webmail.manchester.ac.uk>

Dear developers,

I have a small but more or less well defined inquiry. Another, more  
general one for which I was not able to find information is towards  
the end of this messages. The question seems to be too technical for  
R-help, that is why I post it here.

When installing packages (Windows XP), occasionally the installation  
does not complete because, it seems, Windows locks some files. I  
normally ignore this as a minor annoyance but now I wish to ask  
students to install a number of often used packages by sourcing an R  
file and this becomes a problem.

Here is an example:

> install.packages( file.path(fp,"fgui_1.0-0.zip"     ), repos=NULL)
Warning in install.packages(file.path(fp, "fgui_1.0-0.zip"), repos = NULL) :
   argument 'lib' is missing: using 'p:/Rpack'
package 'fgui' successfully unpacked and MD5 sums checked
Error in normalizePath(path) :
   path[1]="p:\Rpack/fgui": The system cannot find the file specified


The circumstances are difficult to reproduce. For some reason, the  
system does not like "fgui" and maybe other packages. The p: drive  
above is network attached and and I have read/write access. Here is  
the result of traceback.

> traceback()
7: normalizePath(instPath)
6: sprintf(gettext(fmt, domain = domain), ...)
5: gettextf("unable to move temporary installation '%s' to '%s'",
        normalizePath(file.path(tmpDir, curPkg)), normalizePath(instPath))
4: warning(gettextf("unable to move temporary installation '%s' to '%s'",
        normalizePath(file.path(tmpDir, curPkg)), normalizePath(instPath)),
        domain = NA, call. = FALSE, immediate. = TRUE)
3: unpackPkg(pkgs[i], pkgnames[i], lib)
2: .install.winbinary(pkgs = pkgs, lib = lib, contriburl = contriburl,
        method = method, available = available, destdir = destdir,
        dependencies = dependencies, ...)
1: install.packages(file.path(fp, "fgui_1.0-0.zip"), repos = NULL)

The error seems to be thrown by the folloing chunk towards the end of  
.install.winbinary():

   ret <- file.rename(file.path(tmpDir, curPkg), instPath)
   if(!ret)
     warning(gettextf("unable to move temporary installation '%s' to '%s'",
                      normalizePath(file.path(tmpDir, curPkg)),
                      normalizePath(instPath)),
              domain = NA, call. = FALSE, immediate. = TRUE)
   ...

Apparently, renaming failed and a message is displayed.
The failure of rename.file may have left the directory specified by  
'instPath' non-existent which may cause normalizePath to fail. When  
this happens
the message printed is not that of warninig() but the one from  
normalizePath() which is uninformative for the user. Maybe an  
additional check here would be appropriate and, given that the  
installation has been basically successful at this point, even an  
attempt to copy the directory after the refusal by Windows to rename  
it? I understand of course that the developers have better things to  
do than to wrestle with the caprice of Windows.


====
Here is a more general enquiry.

I am using R in a statistics course (about 100) students in a computer  
cluster where R is installed on a server, students run WindowsXP and  
to my understanding the program is run by something called "Zen". It  
seems that if a number of students try loading packages, things become  
extremely slow and loading fails for some.

The IT services claim that R is the culprit, I am not sure and  
certainly part of the problem is related to the slow speed of the  
network, but a few problems seem to be related to permissions. I tried  
using options(timeout=N) even trying ridiculous values for N but this  
did not improve things.

I was not able to trace discussions of such issues and wonder if  
somebody has encountered similar problems.

I am about to try ask the students to install some packages in their  
area (called p: drive at this Uni) which prompted the first question  
above.

Thank you for any suggestions,
Georgi


-- 
Dr Georgi Boshnakov               tel: (+44) (0)161 306 3684
School of Mathematics             fax: (+44) (0)161 306 3669
Alan Turing Building 1.125
The University of Manchester      email: Georgi.Boshnakov at manchester.ac.uk
Oxford Road
Manchester M13 9PL
UK



[Rd] install.packages, normalizePath, file permissions
Georgi Boshnakov