Closed gmbecker closed 1 year ago
Moved to rcmdcheck since that seems to be the source of the problem.
In corporate, shared computing environments (notably including RStudio server pro installations), site profiles are used extensively to configure e.g., libpaths and repositories.
callr respects libpaths and also repositories, it uses the values of the current session:
❯ dir.create(tmp <- tempfile())
❯ .libPaths(c(tmp, .libPaths()))
❯ .libPaths()
[1] "/private/var/folders/ph/fpcmzfd16rgbbk8mxvy9m2_h0000gn/T/RtmpwEQzvx/file8b21da1ecc2"
[2] "/Users/gaborcsardi/Library/R/arm64/4.2/library"
[3] "/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library"
❯ callr::r(function() .libPaths())
[1] "/private/var/folders/ph/fpcmzfd16rgbbk8mxvy9m2_h0000gn/T/RtmpwEQzvx/file8b21da1ecc2"
[2] "/Users/gaborcsardi/Library/R/arm64/4.2/library"
[3] "/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library"
If the libpath and the repos
option is respected, then is there anything else that you need from the profile?
Otherwise, it is best to ignore profiles in most cases, because people load packages in them, and that's probably not something you want for R CMD check
.
Hi @gaborcsardi,
R CMD check hits both the user and site profile out of the box. I would expect rcmdcheck to do the same by default, even you want to leave that configurable so it can be turned off, e.g., in the situations you describe.
We can't change the default, that is a breaking change.
Do you have an example where the current behavior is causing problems?
It would be a user-facing change in behavior, yes. The current behavior isn't right though, for the reasons I stated above. Currently rcmdcheck does not do the same thing as R CMD check run from a terminal on the same machine, a fact which as far as I can tell is not directly documented anywhere.
But even if the default behavior remains incorrect, neither devtools::check
nor rcmdcheck
accept the system_profile
and user_profile
arguments at all so it's not overridable.
And yes, when devtools::check
is invoked from the build menu in Rstudio Server, something happens that causes the issue I describe, in practice, in a real corporate setting. Running R CMD check (by turning devtools funcs off in the build tools config or by running it from the terminal pane) works fine as it hits the necessary site profile.
works fine as it hits the necessary site profile.
I am sorry, what I am trying to ask is, what do you need from the site profile?
Currently rcmdcheck does not do the same thing as R CMD check run from a terminal on the same machine
I just tried and R -q -e 'rcmdcheck::rcmdcheck(...)'
sets the library path and also the repos option for the check process, to the same values as the profiles would set them in a regular R process.
This is why I am asking, what other option or setting do you have in the profile that is important for the check?
repos is the one that the client is being bitten by. They are not set when devtools::check is invoked via the build tools menu/button in Rstudio. I can't speak to why not, but I can tell you it doesn't.
When "use devtools functions when available" is unchecked, and R CMD check invoked directly by the IDE, the site profile is hit and everything works.
That's probably on RStudio then, it passes --vanilla
to the R process that starts the check:
> ps::ps_cmdline(ps::ps_children()[[2]])
[1] "/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/bin/exec/R"
[2] "--vanilla"
[3] "-s"
[4] "-e"
[5] "devtools::check(document~+~=~+~FALSE,~+~check_dir~+~=~+~dirname(getwd()))"
But they do not pass --vanilla
to the non-devtools check:
> ps::ps_cmdline(ps::ps_children()[[2]])
[1] "sh"
[2] "/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/bin/Rcmd"
[3] "check"
[4] "dotenv_1.0.3.9000.tar.gz"
As this is something to be addressed in RStudio, I am going to close it here.
In corporate, shared computing environments (notably including RStudio server pro installations), site profiles are used extensively to configure e.g., libpaths and repositories.
devtools::check, however, ultimately starts an R process to run R CMD check that doesn't respect that site profile, due to this being the default behavior of
callr::rcmd_safe
, which devtools::check (after multiple levels of redirection) calls to actually perform the check.This renders devtools::check unusable in these contexts. At the very least, there should be an argument to
devtools::check
which is passed down all the way tocallr::rcmd_safe
, but even beyond that, it really seems like the default (or only) behavior should be to mimic its parent process which, unless it was run with,e .g.,--vanilla
will be using the site profile if one exists.Callstack from check to rcmd_safe:
Session info: