如何在devtools::check()中正确指定env_vars参数?
devtools::check() It looks like the issue here is how you're passing the environment variable to devtools::check(). The env_vars parameter expects a named list or named vector of key-value pairs, not a single string with an = sign.
Your current code treats the entire string _R_S3_METHOD_LOOKUP_BASEENV_AFTER_GLOBALENV_= TRUE as an unnamed environment variable, which is why the output shows that odd formatting with an extra colon before the variable string.
Correct Ways to Set the Environment Variable
You have two straightforward fixes here:
1. Use a Named List
This is the most intuitive approach, especially for logical values:
devtools::check( document = FALSE, env_vars = list( _R_S3_METHOD_LOOKUP_BASEENV_AFTER_GLOBALENV_ = TRUE ) )
2. Use a Named Vector
If you prefer using a vector, make sure the value is a string (since environment variables are stored as strings under the hood):
devtools::check( document = FALSE, env_vars = c( "_R_S3_METHOD_LOOKUP_BASEENV_AFTER_GLOBALENV_" = "TRUE" ) )
Expected Output After Fix
Once you use either of these formats, the Setting env vars section of the output will match your desired result:
Setting env vars -------------------------------------------- _R_CHECK_CRAN_INCOMING_ : FALSE _R_CHECK_FORCE_SUGGESTS_ : FALSE _R_S3_METHOD_LOOKUP_BASEENV_AFTER_GLOBALENV_ : TRUE
内容的提问来源于stack exchange,提问作者swihart

