tidyverse / reprex

Render bits of R code for sharing, e.g., on GitHub or StackOverflow.

Home Page:https://reprex.tidyverse.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

reprex:::reprex_addin() on posit cloud does not show the preview

RaymondBalise opened this issue · comments

I was trying to demo {reprex} to students yesterday and when I used Render reprex... from the Addins context specific menu:

image

and checked on Preview HTML

image

the reprex was rendered but there was no preview.

image

raw_data <- data.frame(person = "ray", mood = "confused")
data$mood
#> Error in data$mood: object of type 'closure' is not subsettable

Created on 2023-02-02 with reprex v2.0.2

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.2.2 (2022-10-31)
#>  os       Ubuntu 20.04.5 LTS
#>  system   x86_64, linux-gnu
#>  ui       X11
#>  language (EN)
#>  collate  C.UTF-8
#>  ctype    C.UTF-8
#>  tz       UTC
#>  date     2023-02-02
#>  pandoc   2.19.2 @ /usr/lib/rstudio-server/bin/quarto/bin/tools/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version date (UTC) lib source
#>  cli           3.6.0   2023-01-09 [1] RSPM (R 4.2.0)
#>  digest        0.6.31  2022-12-11 [1] RSPM (R 4.2.0)
#>  evaluate      0.19    2022-12-13 [1] RSPM (R 4.2.0)
#>  fastmap       1.1.0   2021-01-25 [1] RSPM (R 4.2.0)
#>  fs            1.5.2   2021-12-08 [1] RSPM (R 4.2.0)
#>  glue          1.6.2   2022-02-24 [1] RSPM (R 4.2.0)
#>  highr         0.10    2022-12-22 [1] RSPM (R 4.2.0)
#>  htmltools     0.5.4   2022-12-07 [1] RSPM (R 4.2.0)
#>  knitr         1.41    2022-11-18 [1] RSPM (R 4.2.0)
#>  lifecycle     1.0.3   2022-10-07 [1] RSPM (R 4.2.0)
#>  magrittr      2.0.3   2022-03-30 [1] RSPM (R 4.2.0)
#>  purrr         1.0.1   2023-01-10 [1] RSPM (R 4.2.0)
#>  R.cache       0.16.0  2022-07-21 [1] RSPM (R 4.2.0)
#>  R.methodsS3   1.8.2   2022-06-13 [1] RSPM (R 4.2.0)
#>  R.oo          1.25.0  2022-06-12 [1] RSPM (R 4.2.0)
#>  R.utils       2.12.2  2022-11-11 [1] RSPM (R 4.2.0)
#>  reprex        2.0.2   2022-08-17 [1] RSPM (R 4.2.0)
#>  rlang         1.0.6   2022-09-24 [1] RSPM (R 4.2.0)
#>  rmarkdown     2.19    2022-12-15 [1] RSPM (R 4.2.0)
#>  rstudioapi    0.14    2022-08-22 [1] RSPM (R 4.2.0)
#>  sessioninfo   1.2.2   2021-12-06 [1] RSPM (R 4.2.0)
#>  stringi       1.7.12  2023-01-11 [1] RSPM (R 4.2.0)
#>  stringr       1.5.0   2022-12-02 [1] RSPM (R 4.2.0)
#>  styler        1.8.1   2022-11-07 [1] RSPM (R 4.2.0)
#>  vctrs         0.5.1   2022-11-16 [1] RSPM (R 4.2.0)
#>  withr         2.5.0   2022-03-03 [1] RSPM (R 4.2.0)
#>  xfun          0.36    2022-12-21 [1] RSPM (R 4.2.0)
#>  yaml          2.3.6   2022-10-18 [1] RSPM (R 4.2.0)
#> 
#>  [1] /cloud/lib/x86_64-pc-linux-gnu-library/4.2
#>  [2] /opt/R/4.2.2/lib/R/library
#> 
#> ──────────────────────────────────────────────────────────────────────────────

If I use the console, everything works as it should:

reprex::reprexO

image

I am teaching novices. So lightening their memory load, by only requiring them to recognize the name reprex from the menu, instead of having to recall the package name then :: and the function is highly preferable.

Help...

I can reproduce this and so far I don't have any theory on why it's happening. I'm going to ask the posit cloud team.

If I walk through the code in the debugger, the problem goes away 😬