r-lib / fs

Provide cross platform file operations based on libuv.
https://fs.r-lib.org/
Other
365 stars 80 forks source link

PATH_MAX still an issue despite Windows setting allowing longer paths #420

Open sda030 opened 1 year ago

sda030 commented 1 year ago

Rendering Quarto chunks errors if path is too long, (but confusingly enough not an issue when rendering the entire document using the Render-button or through the quarto-package). I have already set Windows 11 to allow extended filepaths. After some digging it seem that fs is clinging to old MAX_PATH/PATH_MAX behaviour, even though libuv removed this limit in 2020. image

fs::path("C:/Users/username/NIFU/21206 Utdanningsdirektoratets spørringer - General/V2023/Rapport/saros/Kap-Behov omkring kvalitetssikring/Behov-omkring-kvalitetsutvikling_cache/html/fig-html_bi_catcat_freq_plot_html_Bruker_skolen_bestemte_analyseverktøy_i_arbeidet_med_å_analysere_og_tolke_resultater__BY_fylke_gs_596_bec41d4ecbe948e793244e4d3177642d.rdb")
#> Error in path_tidy(.Call(fs_path_, lapply(args, function(x) enc2utf8(as.character(x))), : Total path length must be less than PATH_MAX: 260

Created on 2023-05-08 with reprex v2.0.2

Session info ``` r sessioninfo::session_info() #> ─ Session info ─────────────────────────────────────────────────────────────── #> setting value #> version R version 4.3.0 (2023-04-21 ucrt) #> os Windows 11 x64 (build 22621) #> system x86_64, mingw32 #> ui RTerm #> language (EN) #> collate nb.utf8 #> ctype nb.utf8 #> tz Europe/Oslo #> date 2023-05-08 #> pandoc 2.19.2 @ C:/Program Files/RStudio/resources/app/bin/quarto/bin/tools/ (via rmarkdown) #> #> ─ Packages ─────────────────────────────────────────────────────────────────── #> package * version date (UTC) lib source #> cli 3.6.1 2023-03-23 [1] CRAN (R 4.2.3) #> digest 0.6.31 2022-12-11 [1] CRAN (R 4.2.3) #> evaluate 0.21 2023-05-05 [1] CRAN (R 4.3.0) #> fastmap 1.1.1 2023-02-24 [1] CRAN (R 4.2.3) #> fs 1.6.2 2023-04-25 [1] CRAN (R 4.3.0) #> glue 1.6.2 2022-02-24 [1] CRAN (R 4.2.3) #> htmltools 0.5.5 2023-03-23 [1] CRAN (R 4.2.3) #> knitr 1.42 2023-01-25 [1] CRAN (R 4.2.3) #> lifecycle 1.0.3 2022-10-07 [1] CRAN (R 4.2.3) #> magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.2.3) #> purrr 1.0.1 2023-01-10 [1] CRAN (R 4.2.3) #> R.cache 0.16.0 2022-07-21 [1] CRAN (R 4.2.3) #> R.methodsS3 1.8.2 2022-06-13 [1] CRAN (R 4.2.2) #> R.oo 1.25.0 2022-06-12 [1] CRAN (R 4.2.2) #> R.utils 2.12.2 2022-11-11 [1] CRAN (R 4.2.3) #> reprex 2.0.2 2022-08-17 [1] CRAN (R 4.2.3) #> rlang 1.1.1 2023-04-28 [1] CRAN (R 4.3.0) #> rmarkdown 2.21 2023-03-26 [1] CRAN (R 4.2.3) #> rstudioapi 0.14 2022-08-22 [1] CRAN (R 4.2.3) #> sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.2.3) #> styler 1.9.1 2023-03-04 [1] CRAN (R 4.2.3) #> vctrs 0.6.2 2023-04-19 [1] CRAN (R 4.2.3) #> withr 2.5.0 2022-03-03 [1] CRAN (R 4.2.3) #> xfun 0.39 2023-04-20 [1] CRAN (R 4.2.3) #> yaml 2.3.7 2023-01-23 [1] CRAN (R 4.2.3) #> #> [1] C:/Users/py128/AppData/Local/R/win-library #> [2] C:/Program Files/R/R-4.3.0/library #> #> ────────────────────────────────────────────────────────────────────────────── ```

P.S. Trying to roll out Quarto to my organization coming weeks and months and there is no alternative with shorter (relative) paths, so would be superbly happy for a fix soon.

Arthfael commented 2 days ago

Similar problem here: I have long paths enabled in Windows but get:

> fs::dir_copy(wd, outdir, overwrite = FALSE)
Error in path_tidy(.Call(fs_path_, lapply(args, function(x) enc2utf8(as.character(x))),  : 
  Total path length must be less than PATH_MAX: 260

I am not sure as to even why I get the problem, because my longest paths seem to be shorter than PATH_MAX:

> a <- list.files(wd, full.names = TRUE, recursive = TRUE)
> b <- gsub(topattern(wd), outdir, a) # (topattern = homebrew function to convert a string to a regex pattern)
> max(nchar(a))
[1] 252
> max(nchar(b))
[1] 237

R version 4.3.2 (2023-10-31 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows Server 2022 x64 (build 20348)