Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Path separator consistency on Windows #38

Open
cderv opened this issue Jul 7, 2021 · 1 comment
Open

Path separator consistency on Windows #38

cderv opened this issue Jul 7, 2021 · 1 comment
Labels
feature a feature request or enhancement

Comments

@cderv
Copy link

cderv commented Jul 7, 2021

For now it is just an observation and it does not cause issue directly. However, it seems not quite right to have different path separator in the same PATH.

On windows, the path separator is not consistent when path are built - see below

# \\ at the beggining, / at the end. 
rappdirs::user_cache_dir("dummy", version = "1.1.0")
#> [1] "C:\\Users\\chris\\AppData\\Local/dummy/dummy/1.1.0/Cache"

# this is because this does not use .Platform$file.sep
rappdirs:::win_path("local")
#> [1] "C:\\Users\\chris\\AppData\\Local"

# but is used as based with file_path using the sep
rappdirs:::file_path("a", "b")
#> [1] "a/b"
dir <- rappdirs:::file_path(rappdirs:::win_path("local"), "dummy", "1.1.0")
dir
#> [1] "C:\\Users\\chris\\AppData\\Local/dummy/1.1.0"

# Path needs to be normalize to be consistent
fs::path_norm(dir)
#> C:/Users/chris/AppData/Local/dummy/1.1.0

# But R 4.0+ does the same so maybe it is expected ? 
tools::R_user_dir("dummy", "cache")
#> [1] "C:\\Users\\chris\\AppData\\Local/R/cache/R/dummy"

Created on 2021-07-07 by the reprex package (v2.0.0)

Is the good practice to normalize the path built anyway ?

@gaborcsardi gaborcsardi added the feature a feature request or enhancement label Nov 1, 2023
@gaborcsardi
Copy link
Member

Yes, I think we could probably be more explicit about path separators on Windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants