Skip to content
New issue

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

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

Already on GitHub? # to your account

V.minor - several usethis functions print an extra escape backslash character in their R output compared to what they say they have written in file #2095

Closed
remlapmot opened this issue Jan 23, 2025 · 1 comment

Comments

@remlapmot
Copy link

This is super minor but I notice that several usethis functions print an extra escape backslash in the R console compared to what they claim they have written in a file.

Here’s a reprex.

library(usethis)
file.remove(".Rbuildignore")
#> [1] TRUE
use_github_action("check-standard.yaml")
#> ✔ Setting active project to "/Users/eptmp/Documents/GitHub/usethis-reprex".
#> ✔ Adding "^\\.github$" to '.Rbuildignore'.
#> ✔ Saving "r-lib/actions/examples/check-standard.yaml@v2" to
#>   '.github/workflows/R-CMD-check.yaml'.
#> ☐ Learn more at <https://github.com/r-lib/actions/blob/v2/examples/README.md>.
#> ☐ Copy and paste the following lines into 'README.md':
#>   <!-- badges: start -->
#>   [![R-CMD-check](https://github.com/remlapmot/usethis-reprex/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/remlapmot/usethis-reprex/actions/workflows/R-CMD-check.yaml)
#>   <!-- badges: end -->
cat(paste0(readLines(".Rbuildignore"), collapse = "\n"))
#> ^\.github$

i.e., the R console prints that ^\\.github$ has been written to .Rbuildignore but in fact ^\.github$ is written in the file.

The create_package() function also does this, there might be others - I haven’t checked all functions.

Created on 2025-01-23 with reprex v2.1.1

Session info

sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.4.2 (2024-10-31)
#>  os       macOS Sequoia 15.2
#>  system   aarch64, darwin20
#>  ui       X11
#>  language (EN)
#>  collate  en_US.UTF-8
#>  ctype    en_US.UTF-8
#>  tz       Europe/London
#>  date     2025-01-23
#>  pandoc   3.6.2 @ /opt/homebrew/bin/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version    date (UTC) lib source
#>  askpass       1.2.1      2024-10-04 [1] CRAN (R 4.4.1)
#>  cli           3.6.3      2024-06-21 [1] CRAN (R 4.4.1)
#>  credentials   2.0.2      2024-10-04 [1] CRAN (R 4.4.1)
#>  curl          6.1.0      2025-01-06 [1] CRAN (R 4.4.1)
#>  digest        0.6.37     2024-08-19 [1] CRAN (R 4.4.1)
#>  evaluate      1.0.3      2025-01-10 [1] CRAN (R 4.4.2)
#>  fastmap       1.2.0      2024-05-15 [1] CRAN (R 4.4.0)
#>  fs            1.6.5      2024-10-30 [1] CRAN (R 4.4.1)
#>  gert          2.1.4      2024-10-14 [1] CRAN (R 4.4.1)
#>  gh            1.4.1      2024-03-28 [1] CRAN (R 4.4.0)
#>  gitcreds      0.1.2      2022-09-08 [1] CRAN (R 4.4.0)
#>  glue          1.8.0      2024-09-30 [1] CRAN (R 4.4.1)
#>  htmltools     0.5.8.1    2024-04-04 [1] CRAN (R 4.4.0)
#>  httr2         1.1.0      2025-01-18 [1] CRAN (R 4.4.2)
#>  jsonlite      1.8.9      2024-09-20 [1] CRAN (R 4.4.1)
#>  knitr         1.49       2024-11-08 [1] CRAN (R 4.4.2)
#>  lifecycle     1.0.4      2023-11-07 [1] CRAN (R 4.4.0)
#>  magrittr      2.0.3      2022-03-30 [1] CRAN (R 4.4.0)
#>  openssl       2.3.1      2025-01-09 [1] CRAN (R 4.4.2)
#>  pillar        1.10.1     2025-01-07 [1] CRAN (R 4.4.1)
#>  pkgconfig     2.0.3      2019-09-22 [1] CRAN (R 4.4.0)
#>  purrr         1.0.2      2023-08-10 [1] CRAN (R 4.4.0)
#>  R6            2.5.1      2021-08-19 [1] CRAN (R 4.4.0)
#>  rappdirs      0.3.3      2021-01-31 [1] CRAN (R 4.4.0)
#>  reprex        2.1.1      2024-07-06 [1] CRAN (R 4.4.1)
#>  rlang         1.1.5      2025-01-17 [1] CRAN (R 4.4.2)
#>  rmarkdown     2.29       2024-11-04 [1] CRAN (R 4.4.2)
#>  rprojroot     2.0.4      2023-11-05 [1] CRAN (R 4.4.0)
#>  rstudioapi    0.17.1     2024-10-22 [1] CRAN (R 4.4.1)
#>  sessioninfo   1.2.2      2021-12-06 [1] CRAN (R 4.4.0)
#>  sys           3.4.3      2024-10-04 [1] CRAN (R 4.4.1)
#>  tibble        3.2.1      2023-03-20 [1] CRAN (R 4.4.0)
#>  usethis     * 3.1.0.9000 2025-01-23 [1] Github (r-lib/usethis@8769507)
#>  vctrs         0.6.5      2023-12-01 [1] CRAN (R 4.4.0)
#>  withr         3.0.2      2024-10-28 [1] CRAN (R 4.4.1)
#>  xfun          0.50       2025-01-07 [1] CRAN (R 4.4.2)
#>  yaml          2.3.10     2024-07-26 [1] CRAN (R 4.4.1)
#> 
#>  [1] /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library
#> 
#> ──────────────────────────────────────────────────────────────────────────────
@jennybc
Copy link
Member

jennybc commented Jan 23, 2025

I think you are reacting to the way strings print in R, i.e. that the escapes are visible in the printed string, but they are not actually present in the string:

https://r4ds.hadley.nz/strings#escapes

@jennybc jennybc closed this as completed Jan 23, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants