Skip to content

checkDirectory() fails on trailing separator (Windows, R < 4.2) #276

@HenningLorenzen-ext-bayer

Description

In old R releases on Windows, there seems to be a little problem with checkDirectory().

Notably, the behaviour of file.exists() has changed with R 4.2 (https://bugs.r-project.org/show_bug.cgi?id=17823#c1).

Reprex

dir.exists("~/")
#> [1] TRUE
fs::dir_exists("~/")
#>   ~/ 
#> TRUE
checkmate::checkDirectory("~/")
#> [1] "Directory '~/' does not exist"
checkmate::checkDirectory("~")
#> [1] TRUE

Created on 2025-02-19 with reprex v2.1.0

Session info
sessioninfo::session_info()
#> - Session info ---------------------------------------------------------------
#>  setting  value
#>  version  R version 4.1.3 (2022-03-10)
#>  os       Windows 10 x64 (build 22621)
#>  system   x86_64, mingw32
#>  ui       RTerm
#>  language (EN)
#>  collate  German_Germany.1252
#>  ctype    German_Germany.1252
#>  tz       unknown
#>  date     2025-02-19
#>  pandoc   3.2 @ C:/Users/[Redacted]/AppData/Local/Programs/RStudio/resources/app/bin/quarto/bin/tools/ (via rmarkdown)
#> 
#> - Packages -------------------------------------------------------------------
#>  package     * version date (UTC) lib source
#>  backports     1.5.0   2024-05-23 [1] RSPM
#>  checkmate     2.3.2   2024-07-29 [1] CRAN (R 4.1.3)
#>  cli           3.6.2   2023-12-11 [1] RSPM
#>  digest        0.6.35  2024-03-11 [1] RSPM
#>  evaluate      0.23    2023-11-01 [1] RSPM
#>  fansi         1.0.6   2023-12-08 [1] RSPM
#>  fastmap       1.2.0   2024-05-15 [1] RSPM
#>  fs            1.6.4   2024-04-25 [1] RSPM
#>  glue          1.7.0   2024-01-09 [1] RSPM
#>  htmltools     0.5.8.1 2024-04-04 [1] RSPM
#>  knitr         1.47    2024-05-29 [1] RSPM
#>  lifecycle     1.0.4   2023-11-07 [1] RSPM
#>  magrittr      2.0.3   2022-03-30 [1] RSPM
#>  pillar        1.9.0   2023-03-22 [1] RSPM
#>  pkgbuild      1.4.4   2024-03-17 [1] RSPM
#>  pkgconfig     2.0.3   2019-09-22 [1] RSPM
#>  purrr         1.0.2   2023-08-10 [1] RSPM
#>  R.cache       0.16.0  2022-07-21 [1] RSPM
#>  R.methodsS3   1.8.2   2022-06-13 [1] RSPM
#>  R.oo          1.26.0  2024-01-24 [1] RSPM
#>  R.utils       2.12.3  2023-11-18 [1] RSPM
#>  R6            2.5.1   2021-08-19 [1] RSPM
#>  reprex        2.1.0   2024-01-11 [1] RSPM
#>  rlang         1.1.4   2024-06-04 [1] RSPM
#>  rmarkdown     2.27    2024-05-17 [1] RSPM
#>  rstudioapi    0.16.0  2024-03-24 [1] RSPM
#>  sessioninfo   1.2.2   2021-12-06 [1] RSPM
#>  styler        1.10.3  2024-04-07 [1] RSPM
#>  tibble        3.2.1   2023-03-20 [1] RSPM
#>  utf8          1.2.4   2023-10-22 [1] RSPM
#>  vctrs         0.6.5   2023-12-01 [1] RSPM
#>  withr         3.0.0   2024-01-16 [1] RSPM
#>  xfun          0.44    2024-05-15 [1] RSPM
#>  yaml          2.3.8   2023-12-11 [1] RSPM
#> 
#>  [1] C:/Users/[Redacted]/AppData/Local/Programs/R/R-4.1.3/site-library
#>  [2] C:/Users/[Redacted]/AppData/Local/Programs/R/R-4.1.3/library
#> 
#> ------------------------------------------------------------------------------

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions