Skip to content

dir_exists sometimes returns FALSE for a relative symlink to a directory #395

@heavywatal

Description

@heavywatal

It is not always, but under some unknown conditions:

x = fs::dir_create(tempfile())
parent = fs::path_dir(x)

abs_ln = fs::link_create(x, fs::path(parent, "abs_ln"))
fs::link_exists(abs_ln)
#> /var/folders/vc/yv3lbg614jv_f7r5046k8yxm0000gn/T/RtmpLxUH0e/abs_ln 
#>                                                               TRUE
fs::dir_exists(abs_ln)
#> /var/folders/vc/yv3lbg614jv_f7r5046k8yxm0000gn/T/RtmpLxUH0e/abs_ln 
#>                                                               TRUE

rel_ln = fs::link_create(fs::path_file(x), fs::path(parent, "rel_ln"))
fs::link_exists(rel_ln)
#> /var/folders/vc/yv3lbg614jv_f7r5046k8yxm0000gn/T/RtmpLxUH0e/rel_ln 
#>                                                               TRUE
fs::dir_exists(rel_ln)
#> /var/folders/vc/yv3lbg614jv_f7r5046k8yxm0000gn/T/RtmpLxUH0e/rel_ln 
#>                                                              FALSE

setwd(parent)
fs::dir_create("path")
rel_ln2 = fs::link_create("path", "new_path")
fs::link_exists("new_path")
#> new_path 
#>     TRUE
fs::dir_exists("new_path")
#> new_path 
#>     TRUE

cat(system2("lsd", c("--tree", parent), stdout = TRUE), sep = "\n")
#> RtmpLxUH0e/
#> ├── abs_ln@ ⇒ /var/folders/vc/yv3lbg614jv_f7r5046k8yxm0000gn/T/RtmpLxUH0e/file772215100b6f
#> ├── file772215100b6f/
#> ├── new_path@ ⇒ path
#> ├── path/
#> └── rel_ln@ ⇒ file772215100b6f

Created on 2022-09-18 with reprex v2.0.2

  • fs 1.5.2
  • R version 4.2.1 (2022-06-23)
  • Platform: x86_64-apple-darwin17.0 (64-bit); macOS 12.5.1
  • Platform: x86_64-pc-linux-gnu (64-bit): Ubuntu 20.04.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions