From mtmorgan at fhcrc.org  Thu Dec  1 18:34:55 2005
From: mtmorgan at fhcrc.org (Martin Morgan)
Date: Thu, 01 Dec 2005 09:34:55 -0800
Subject: [Rd] (not just!) Windows R CMD build <pkg> leftovers
In-Reply-To: <6phacftq4r9.fsf@gopher3.fhcrc.org> (Martin Morgan's message of
	"Thu, 24 Nov 2005 10:28:58 -0800")
References: <6phacftq4r9.fsf@gopher3.fhcrc.org>
Message-ID: <6phvey8yb40.fsf@gopher3.fhcrc.org>

Perhaps this earlier post slipped through the cracks? My apologies if
it's still 'in process', or I missed a response, or if the
contribution isn't helpful.

At any rate, I realized that the problem is not windows-specific.

Also, generating $libdir by calling (a sligthly modified) R_tempfile
might give installation more of a fighting chance in a cluttered TMPDIR.

Index: src/scripts/build.in
===================================================================
--- src/scripts/build.in        (revision 36565)
+++ src/scripts/build.in        (working copy)
@@ -76,7 +76,7 @@
 my $R_platform = R_getenv("R_PLATFORM", "unknown-binary");
 my $gzip = R_getenv("R_GZIPCMD", "gzip");
 my $tar = R_getenv("TAR", "tar");
-my $libdir = &file_path(${R::Vars::TMPDIR}, "Rinst.$$");
+my $libdir = R_tempfile("Rinst.");
 
 my $INSTALL_opts = "";
 $INSTALL_opts .= " --use-zip" if $opt_use_zip;
@@ -434,6 +434,8 @@
            if($doit && R_system($cmd)) {
                $log->error();
                $log->print("Installation failed.\n");
+               $log->print("Removing '$libdir'\n");
+               rmtree($libdir);
                exit(1);
            }
            my $R_LIBS = $ENV{'R_LIBS'};
Index: share/perl/R/Utils.pm
===================================================================
--- share/perl/R/Utils.pm       (revision 36565)
+++ share/perl/R/Utils.pm       (working copy)
@@ -75,7 +75,7 @@
                           $pat . $$ . sprintf("%05d", rand(10**5)));
 
     my $n=0;
-    while(-f $retval){
+    while(-e $retval){
        $retval = file_path($R::Vars::TMPDIR,
                            $pat . $$ . sprintf("%05d", rand(10**5)));
        croak "Cannot find unused name for temporary file"


Martin Morgan <mtmorgan at fhcrc.org> writes:

> A command
>
> R CMD build  <pkg>
>
> that fails, e.g., because of C code compilation errors, leaves a
> directory %TMPDIR%/Rinst.xxx containing the file R.css. Although R
> CMD INSTALL --build cleans up after itself, build does not. A fix is
> below. Also, build.in references Rcmd.exe, which I thought was no
> longer necessary?
>
> Index: build.in
> ===================================================================
> --- build.in	(revision 36450)
> +++ build.in	(working copy)
> @@ -434,6 +434,8 @@
>  	    if($doit && R_system($cmd)) {
>  		$log->error();
>  		$log->print("Installation failed.\n");
> +		$log->print("Removing '$libdir'\n");
> +		rmtree($libdir);
>  		exit(1);
>  	    }
>  	    my $R_LIBS = $ENV{'R_LIBS'};
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



[Rd] (not just!) Windows R CMD build <pkg> leftovers
Martin Morgan