You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在devtools::check()中正确指定env_vars参数?

Fixing Environment Variable Format in 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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 10:10:17