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

Issue with pkg rstudioapi after updating to R 4.4 #1518

Closed
strengejacke opened this issue Apr 29, 2024 · 4 comments · Fixed by #1520
Closed

Issue with pkg rstudioapi after updating to R 4.4 #1518

strengejacke opened this issue Apr 29, 2024 · 4 comments · Fixed by #1520
Labels

Comments

@strengejacke
Copy link

I'm seeing an issue that is new when using the reprex-package. This problem first occurred after updating to R 4.4.0.

My setup is VSCode 1.88.1, Windows 11, R 4.4.0 (64 bit).

Code:

reprex::reprex('data(diamonds, package = "ggplot2")')

Output:

"data(diamonds, package = \"ggplot2\")"
#> [1] "data(diamonds, package = \"ggplot2\")"

Error:

ℹ Rendering reprex...
Error in .make_numeric_version(x, strict, .standard_regexps()$valid_numeric_version) :
  invalid non-character version specification 'x' (type: double)
> reprex::reprex('data(diamonds, package = "ggplot2")')
ℹ Rendering reprex...
Error in .make_numeric_version(x, strict, .standard_regexps()$valid_numeric_version) :
  invalid non-character version specification 'x' (type: double)
> traceback()
9: stop(msg, domain = NA)
8: .make_numeric_version(x, strict, .standard_regexps()$valid_numeric_version)      
7: numeric_version(0) at rstudioapi.R#237
6: rstudioapi::versionInfo()
5: is_rstudio_server()
4: reprex_clipboard()
3: expose_reprex_output(reprex_file, rtf = (venue == "rtf"))
2: reprex_impl(x_expr = substitute(x), input = input, wd = wd, venue = venue,       
       render = render, new_session = TRUE, advertise = advertise,
       session_info = session_info, style = style, html_preview = html_preview, 
       comment = comment, tidyverse_quiet = tidyverse_quiet, std_out_err = std_out_err,
       outfile = outfile)
1: reprex::reprex("data(diamonds, package = \"ggplot2\")")

Seems like rstudioapi::versionInfo() causes the error here:

image

The reprex package maintainer believe it's related to the VSCode R extension:

I think it's this in their rstudioapi shims. Your backtrace seems to be identifying the call is from the shim: 7: numeric_version(0) at rstudioapi.R#237

(tidyverse/reprex#462)

@jooyoungseo
Copy link
Contributor

I have encountered the same issue. This has to do with the VSCode R extension as there is no issue in R term launched in cmd.exe. It seems like the extension is not loading the global Rprofile properly, either.

@uhkeller
Copy link

uhkeller commented May 3, 2024

I'm seeing the same on macOS (so not a Windows issue).

@eitsupi
Copy link
Contributor

eitsupi commented May 3, 2024

As I read the error message, it may be related to the fact that the version of R has been upgraded to make the comparison of numbers and version numbers an error.

@uhkeller
Copy link

uhkeller commented May 3, 2024

Yes, .make_numeric_version() has changed quite a lot from 4.3.3 to 4.4.0 so the shim doesn't work any more. I can make R issue a warning instead of throwing an error by doing this in the session before running reprex::reprex():

Sys.setenv("_R_CHECK_STOP_ON_INVALID_NUMERIC_VERSION_INPUTS_" = "false")

Running the reprex:

r$> reprex::reprex(1+1)
ℹ Rendering reprex...
Warning in .make_numeric_version(x, strict, .standard_regexps()$valid_numeric_version) :
  invalid non-character version specification 'x' (type: double)
✔ Reprex output is on the clipboard.

Result:

1 + 1
#> [1] 2

Created on 2024-05-03 with reprex v2.1.0

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

Successfully merging a pull request may close this issue.

4 participants