From becker.gabe at gene.com  Wed Apr  4 06:16:12 2018
From: becker.gabe at gene.com (Gabe Becker)
Date: Tue, 3 Apr 2018 21:16:12 -0700
Subject: [Rd] Base R examples that write to current working directory
In-Reply-To: <23235.19264.599579.492157@stat.math.ethz.ch>
References: <CABdHhvEDW3nCgwNAXjNcpFtJSM_d=xooX4infq6oTfmctiU3DQ@mail.gmail.com>
 <697bd1b5-4c56-d9b4-55d1-bb70b12aee0c@gmail.com>
 <672879f7-c30d-59ff-fb78-2be575b49002@statistik.tu-dortmund.de>
 <CAFDcVCTu5Cz4r4LFnzBxr4pSp1rzKW8imVBH-3U2zNr2YkS3Vg@mail.gmail.com>
 <23235.19264.599579.492157@stat.math.ethz.ch>
Message-ID: <CAMFmJsmUCqQQeUoMaYevqwiSF2j=p0nzhuexbVPRMxxbHAXBrA@mail.gmail.com>

Martin et al,

I have submitted a patch on bugzilla which fixes all of the examples I
could easily find which were not already writing only to temporary files or
switching to a temp directory before writing files to the working
directory. https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17403

Passes make check-devel so the examples run and the packages that were
modified pass check.

Best,
~G

On Tue, Apr 3, 2018 at 2:37 AM, Martin Maechler <maechler at stat.math.ethz.ch>
wrote:

> >>>>> Henrik Bengtsson <henrik.bengtsson at gmail.com>
> >>>>>     on Fri, 30 Mar 2018 10:14:04 -0700 writes:
>
>     > So, the proposal would then be to write to tempdir(),
>     > correct?  If so, I see three alternatives:
>
>     > 1. explicitly use file.path(tempdir(), filename), or
>     > tempfile() everywhere.
>
> I think it should clearly be  '1.',
> as both '2.' and '3.' would need new functionality in R.
>
> Ideally we'd get the patch within a day or two, so we can safely
> apply it also to  R 3.5.0 alpha  (before it turns beta!).
>
> I think the 'eval.path' argument to example() is a nice idea,
> but also changing its default to  tempdir() is definitely out of
> the question for R 3.5.0.
>
> Martin
>
>
>     > 2. wrap example code in a withTempDir({ ... }) call.
>
>     > 3. Add an 'eval.path' (*) argument to example() and make
>     > it default to eval.path = tempdir(). This would probably
>     > be backward compatible and keep the code example clean.
>     > The downside is when a user runs an example and can't
>     > locate produced files. (*) or 'wd', 'workdir', ...
>
>     > /Henrik
>
>     > On Fri, Mar 30, 2018 at 9:25 AM, Uwe Ligges
>     > <ligges at statistik.tu-dortmund.de> wrote:
>     >>
>     >>
>     >> On 30.03.2018 00:08, Duncan Murdoch wrote:
>     >>>
>     >>> On 29/03/2018 5:23 PM, Hadley Wickham wrote:
>     >>>>
>     >>>> Hi all,
>     >>>>
>     >>>> Given the recent CRAN push to prevent examples writing
>     >>>> to the working directory, is there any interest in
>     >>>> fixing base R examples that write to the working
>     >>>> directory? A few candidates are the graphics devices,
>     >>>> file.create(), writeBin(), writeChar(), write(), and
>     >>>> saveRDS(). I'm sure there are many more.
>     >>>>
>     >>>> One way to catch these naughty examples would be to
>     >>>> search for unlink() in examples: e.g.,
>     >>>>
>     >>>> https://github.com/wch/r-source/search?utf8=?&q=unlink+
> extension%3ARd&type=
> <https://github.com/wch/r-source/search?utf8=%E2%9C%93&q=unlink+extension%3ARd&type=>
> .
>     >>>> Of course, simply cleaning up after yourself is not
>     >>>> sufficient because if those files existed before the
>     >>>> examples were run, the examples will destroy them.
>     >>>>
>     >>>
>     >>> Why not put together a patch that fixes these?  This
>     >>> doesn't seem to be something that needs discussion,
>     >>> fixing the bad examples would be a good idea.
>     >>
>     >>
>     >> Seconded. CRAN would not accept these base packages,
>     >> hence we should urgently give better examples.
>     >>
>     >> Best, Uwe
>     >>
>     >>
>     >>
>     >>> Duncan Murdoch
>     >>>
>     >>> ______________________________________________
>     >>> R-devel at r-project.org mailing list
>     >>> https://stat.ethz.ch/mailman/listinfo/r-devel
>     >>
>     >>
>     >> ______________________________________________
>     >> R-devel at r-project.org mailing list
>     >> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>     > ______________________________________________
>     > R-devel at r-project.org mailing list
>     > https://stat.ethz.ch/mailman/listinfo/r-devel
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>



-- 
Gabriel Becker, Ph.D
Scientist
Bioinformatics and Computational Biology
Genentech Research

	[[alternative HTML version deleted]]



[Rd] Base R examples that write to current working directory
Gabe Becker