Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: use of NULL environment is defunct #1208

Closed
hsbadr opened this issue May 15, 2021 · 6 comments
Closed

Error: use of NULL environment is defunct #1208

hsbadr opened this issue May 15, 2021 · 6 comments

Comments

@hsbadr
Copy link

hsbadr commented May 15, 2021

After #1176, I get the following error:

Error in env_get(env, ".rlang_use_cli_format", default = default, inherit = TRUE,  :
  use of NULL environment is defunct

Here's an example:

vroom::vroom("https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_daily_reports/01-14-2021.csv", altrep = FALSE)

Note that reading this file with altrep = TRUE or using utils::read.csv() (or any other reader that doesn't depend on rlang) is ok. Moreover, other conditions can trigger the same error, such as setting .default in col_types with specific files. None of this happens with the CRAN version of rlang.

This is traced back as follows:

6: env_get(env, ".rlang_use_cli_format", default = default, inherit = TRUE,
       last = last) at cnd-message.R#263
5: use_cli_format(env) at cnd-message.R#230
4: cli_format_warning(message, caller_env()) at cnd-signal.R#110
3: (function (message = NULL, class = NULL, ..., .frequency = c("always",
       "regularly", "once"), .frequency_id = NULL, .subclass = deprecated())
   {
       validate_signal_args(.subclass)
       message <- validate_signal_message(message, class)
       message <- cli_format_warning(message, caller_env())
       .frequency <- arg_match0(.frequency, c("always", "regularly",
           "once"))
       if (needs_signal(.frequency, .frequency_id, warning_freq_env,
           "rlib_warning_verbosity")) {
           message <- add_message_freq(message, .frequency, "warning")
       }
       else {
           return(invisible(NULL))
       }
       cnd <- warning_cnd(class, ..., message = message)
       warning(cnd)
   })("One or more parsing issues, see `problems()` for details",
       "vroom_parse_issue") at cpp11.R#56
2: vroom_(file, delim = delim %||% col_types$delim, col_names = col_names,
       col_types = col_types, id = id, skip = skip, col_select = col_select,
       name_repair = .name_repair, na = na, quote = quote, trim_ws = trim_ws,
       escape_double = escape_double, escape_backslash = escape_backslash,
       comment = comment, locale = locale, guess_max = guess_max,
       n_max = n_max, altrep = vroom_altrep(altrep), num_threads = num_threads,
       progress = progress) at vroom.R#152
1: vroom::vroom("https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_daily_reports/01-14-2021.csv",
       altrep = FALSE)
@lionel-
Copy link
Member

lionel- commented May 17, 2021

Unfortunately I can't reproduce this. Do you see the issue in other situations?

@hsbadr
Copy link
Author

hsbadr commented May 17, 2021

This happens under R-devel with packages installed from GitHub. It seems that the problem is in the use of caller_env() in the internal cli_format_warning function, if somehow env is empty:

> rlang:::cli_format_warning("Hi", rlang::empty_env())
Error in env_get(env, ".rlang_use_cli_format", default = default, inherit = TRUE,  :
  use of NULL environment is defunct

@hsbadr
Copy link
Author

hsbadr commented May 17, 2021

This is traced back to:

> rlang:::use_cli_format(rlang::empty_env())
Error in env_get(env, ".rlang_use_cli_format", default = default, inherit = TRUE,  :
  use of NULL environment is defunct

@lionel-
Copy link
Member

lionel- commented May 17, 2021

Ah perhaps I needed dev vroom to reproduce? Either way I can reproduce your minimal reprex with rlang:::use_cli_format(), thanks! On both r-release and r-devel.

@hsbadr
Copy link
Author

hsbadr commented May 17, 2021

Thanks @lionel- ! I don't know exactly why the caller_env() is empty, which is the culprit here, but can you catch it in cli_format_warning, use_cli_format or env_get? I don't run into this issue on R-release.

@hsbadr
Copy link
Author

hsbadr commented May 17, 2021

Ah perhaps I needed dev vroom to reproduce?

Yes, I've just reproduced this issue with the dev version of both vroom and rlang on R-release too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants