fs icon indicating copy to clipboard operation
fs copied to clipboard

dir_exists hangs up with a broken autoloop symlink

Open heavywatal opened this issue 3 years ago • 2 comments

while base::dir.exists() returns FALSE quickly:

fs::link_create("autoloop", "autoloop")
base::file.exists("autoloop")
#> [1] FALSE
base::dir.exists("autoloop")
#> [1] FALSE
fs::file_exists("autoloop")
#> autoloop 
#>    FALSE
fs::link_exists("autoloop")
#> autoloop 
#>     TRUE
fs::dir_exists("autoloop")
^C

heavywatal avatar Sep 18 '22 05:09 heavywatal

This boils down to

file_info("autoloop", follow = TRUE)

This is what the standard Unix tools do and we could do the same.

❯ realpath autoloop
realpath: autoloop: Too many levels of symbolic links

IDK how many is too many, though.

gaborcsardi avatar Sep 20 '22 12:09 gaborcsardi

Based on https://man7.org/linux/man-pages/man7/path_resolution.7.html the limit is 40 for modern Linux kernels.

gaborcsardi avatar Sep 20 '22 12:09 gaborcsardi