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

Adam @@eb@@dow@k| @end|ng |rom gm@||@com
Sun Nov 19 00:07:20 CET 2023


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/",
    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>
wrote:

> Adam,
>
>
> > On Nov 19, 2023, at 9:39 AM, Adam <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