CRAN policy and Bioconductor policy
4
0
Entering edit mode
mattocci27 • 0
@mattocci27-7128
Last seen 7.8 years ago
United States

Hi,

I made an R package and one of the function in the package creates a macro text file for other software. However, according to the CRAN policy, writing in the user’s home directory is regarded as malicious or anti-soiical. Is this function also prohibited in Bioconductor? I checked the Bioconductor policy but I didn’t find that kind of description.

Thanks,

Masatoshi

r cran • 1.5k views
1
Entering edit mode
Dan Tenenbaum ★ 8.2k
@dan-tenenbaum-4256
Last seen 19 months ago
United States

This is probably more of a question for the bioc-devel list.

I don't think there is an official policy on this. But I'd like to have a better idea of what your package actually does. If it writes to a hidden file or directory in the users home directory just to save some state, that might be ok. But I'm not sure what a "macro text file for other software" is.

Dan

1
Entering edit mode

It's probably good too to think of the CRAN policy as directing you toward good programming practice -- don't write to a user's directory without their explicit permission (e.g., add an argument 'destination' to the function that will generate the macro, perhaps with a default value tempfile()) -- rather than some kind of policy that you should try and avoid (e.g., by submitting to Bioconductor!).

1
Entering edit mode
@gordon-smyth
Last seen 8 hours ago
WEHI, Melbourne, Australia

You are presumably reacting to the following lines from the CRAN policy document:

"The code and examples provided in a package should never do anything which might be regarded as malicious or anti-social. The following are illustrative examples from past experience.

• Packages should not write in the users’ home filespace, nor anywhere else on the file system apart from the R session’s temporary directory (or during installation in the location pointed to by TMPDIR: and such usage should be cleaned up). Installing into the system’s R installation (e.g., scripts to its bin directory) is not allowed."

This is presumably to dissuade packages from writing to a user's filespace without the user's knowledge, which is indeed antisocial.

There is however no problem with functions such as write.table() or writeLines() which write files at the user's request. I doubt that there is any major difference between CRAN and Bioconductor policy on this.

0
Entering edit mode
mattocci27 • 0
@mattocci27-7128
Last seen 7.8 years ago
United States

Hi all,

Thank you very much for the helpful comments. I understood the policy. Using tempfile( ) works this time.

0
Entering edit mode
@henrik-bengtsson-4333
Last seen 12 days ago
United States

The R.cache package, for memoization, caches computational expensive results to file.  Ideally this cache lives beyond a single R session, which requires to write to a specific directory and therefore tempdir() is not sufficient.  What I ended up doing, was to ask the user to accepts to use '~/.Rcache/' when the package was loaded in an interactive session.  If not approved, the package uses a session-specific temporary directory.  If once approved, the directories will be used in all following sessions

The above approach meets the CRAN Policy, which also says "Limited exceptions may be allowed in interactive sessions if the package obtains confirmation from the user".

EXAMPLE:

A first-time user of R.cache experiences:

> file_test("-d", "~/.Rcache/")
[1] FALSE
> library("R.cache")
The R.cache package needs to create a directory that will hold cache files. It
is convenient to use one in the user's home directory, because it remains also
af ter restarting R. Do you wish to create the '~/.Rcache/' directory? If not,
a temporary directory (C:\Users\hb\AppData\Local\Temp\Rtmp8ajw0O/.Rcache) that
is specific to this R session will be used. [Y/n]: Y
R.cache v0.10.0 (2014-06-10) successfully loaded. See ?R.cache for help.
> file_test("-d", "~/.Rcache/")
[1] TRUE