[R-pkg-devel] Cryptic error on Windows but not Debian

Simon Urbanek @|mon@urb@nek @end|ng |rom R-project@org
Sun Nov 19 00:14:00 CET 2023


Adam,

no, it is your code in mm_authorize() that violates the CRAN policy, it is not about the test. You may not touch user's .Renviron and there is no reason to resort to such drastic measures. If you want to cache user's credentials, you have to do it in a file located via tools::R_user_dir().

Cheers,
Simon


> On Nov 19, 2023, at 12:07 PM, Adam <asebsadowski using gmail.com> wrote:
> 
> Thank you dearly, Simon, for pointing out the policy. May a test do the following?
> 
> 1. Save the user's original value for env var X.
> 2. Write a new value for env var X during a test.
> 3. Write back the original value for env var X at the end of the test.
> 
> An example:
> 
> test_that("mm_authorize() sets credentials", {
>   skip_on_cran()
>   key_original <- mm_key()
>   url_original <- mm_url()
>   withr::defer({
>     mm_authorize(
>       key = key_original,
>       url = url_original,
>       overwrite = TRUE
>     )
>   })
>   mm_authorize(
>     key = "1",
>     url = "https://api.megamation.com/uw/joe/ <https://api.megamation.com/uw/joe/>",
>     overwrite = TRUE
>   )
>   expect_false(
>     endsWith(Sys.getenv("MEGAMATION_URL"), "/")
>   )
> })
> 
> Best,
> Adam
> 
> 
> On Sat, Nov 18, 2023 at 4:52 PM Simon Urbanek <simon.urbanek using r-project.org <mailto:simon.urbanek using r-project.org>> wrote:
> Adam,
> 
> 
> > On Nov 19, 2023, at 9:39 AM, Adam <asebsadowski using gmail.com <mailto:asebsadowski using gmail.com>> wrote:
> > 
> > Dear Ivan,
> > 
> > Thank you for explaining in such depth. I had not submitted to CRAN before.
> > I will look into tools::R_user_dir().
> > 
> > - May you point me toward the policy that the package should not edit .Renviron?
> 
> 
> It is the policy you have agreed to when submitting your package to CRAN:
> 
> "CRAN Repository Policy
> [...]
> 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 user’s home filespace (including clipboards), nor anywhere else on the file system apart from the R session’s temporary directory. [...]
>   For R version 4.0 or later (hence a version dependency is required or only conditional use is possible), packages may store user-specific data, configuration and cache files in their respective user directories obtained from tools::R_user_dir(), provided that by default sizes are kept as small as possible and the contents are actively managed (including removing outdated material).
> "
> 
> Cheers,
> Simon
> 


	[[alternative HTML version deleted]]



More information about the R-package-devel mailing list