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

How does fs resolve "C:/"? Seems to point to working directory instead #124

Closed
vnijs opened this Issue Jul 20, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@vnijs
Copy link

vnijs commented Jul 20, 2018

fs::dir_ls("C:") shows directories such as Program Files correctly on my windows VM on macOS. However, when running on a Windows laptop, fs::dir_ls("C:/") points to the current working directory instead. See example below. As you can see, the information provided for "C:/" changes after the working directory is changed which seems odd.

> fs::dir_ls("C:/", all = TRUE)
C:/.git              C:/.gitattributes    C:/.gitignore        
C:/.Rbuildignore     C:/.Rproj.user       C:/.travis.yml       
C:/build             C:/DESCRIPTION       C:/file_ext_parser.R 
C:/inst              C:/man               C:/NAMESPACE         
C:/R                 C:/README.md         C:/shinyfiles.Rproj  
> setwd("man")
> fs::dir_ls("C:/", all = TRUE)
C:/dirCreator.Rd           C:/dirGetter.Rd            
C:/figures                 C:/fileGetter.Rd           
C:/formatFiletype.Rd       C:/getVolumes.Rd           
C:/shinyFiles-buttons.Rd   C:/shinyFiles-observers.Rd 
C:/shinyFiles-package.Rd   C:/shinyFiles-parsers.Rd   
C:/shinyFilesExample.Rd    C:/traverseDirs.Rd         
C:/updateChildren.Rd 
> setwd("C:/")
> fs::dir_ls("C:/")
C:/$GetCurrent                    C:/$RECYCLE.BIN                   
C:/46505c85a851763c67c2ed05752bfe C:/4a7c5b0e4e99506a9da03a         
C:/AMTAG.BIN                      C:/BOOTNXT                        
C:/Config.Msi                     C:/Documents and Settings         
C:/found.000                      C:/hiberfil.sys                   
C:/Intel                          C:/Logs                           
C:/MSOCache                       C:/pagefile.sys                   
C:/PerfLogs                       C:/Program Files                  
C:/Program Files (x86)            C:/ProgramData                    
C:/R                              C:/Recovery                       
C:/RECYCLER                       C:/Rtools                         
C:/swapfile.sys                   C:/System Volume Information      
C:/Users                          C:/Windows                        
C:/Windows10Upgrade 
> devtools::session_info()
Session info ------------------------------------------------------------------
 setting  value                       
 version  R version 3.5.1 (2018-07-02)
 system   x86_64, mingw32             
 ui       RStudio (1.2.792)           
 language (EN)                        
 collate  English_United States.1252  
 tz       America/Los_Angeles         
 date     2018-07-20                  

Packages ----------------------------------------------------------------------
 package    * version    date       source                   
 base       * 3.5.1      2018-07-02 local                    
 compiler     3.5.1      2018-07-02 local                    
 crayon       1.3.4      2017-09-16 CRAN (R 3.5.0)           
 datasets   * 3.5.1      2018-07-02 local                    
 devtools     1.13.6     2018-06-27 CRAN (R 3.5.1)           
 digest       0.6.15     2018-01-28 CRAN (R 3.5.0)           
 fs           1.2.3      2018-07-20 Github (r-lib/fs@1528958)
 graphics   * 3.5.1      2018-07-02 local                    
 grDevices  * 3.5.1      2018-07-02 local                    
 memoise      1.1.0      2017-04-21 CRAN (R 3.5.1)           
 methods    * 3.5.1      2018-07-02 local                    
 Rcpp         0.12.17    2018-05-18 CRAN (R 3.5.0)           
 rstudioapi   0.7.0-9001 2018-05-25 local                    
 stats      * 3.5.1      2018-07-02 local                    
 tools        3.5.1      2018-07-02 local                    
 utils      * 3.5.1      2018-07-02 local                    
 withr        2.1.2      2018-03-15 CRAN (R 3.5.0)  
@vnijs

This comment has been minimized.

Copy link
Author

vnijs commented Jul 21, 2018

Perhaps related. I expect "C:/" should not be changed in the call below.

> fs::path("C:/")
C:
> file.exists("C:")
[1] FALSE
> file.exists("C:/")
[1] TRUE

Just noticed a difference between file.exists and fs::file_exists:

> file.exists("C:")
[1] FALSE
> fs::file_exists("C:")
  C: 
TRUE 

@vnijs vnijs changed the title How does fs resolve "C:/"? Seems to point to working directory insteadh How does fs resolve "C:/"? Seems to point to working directory instead Jul 21, 2018

@jimhester jimhester added the bug label Jul 24, 2018

@jimhester jimhester closed this in 0f2de7a Jul 24, 2018

@vnijs

This comment has been minimized.

Copy link
Author

vnijs commented Jul 24, 2018

Works great! Thanks @jimhester

jdblischak added a commit to jdblischak/workflowr that referenced this issue Oct 22, 2018

Set minimum version of fs.
Support for trailing slash of Windows drive introduced in v1.24. I had
been testing in v1.2.3.

https://github.com/r-lib/fs/blob/master/NEWS.md#fs-124
r-lib/fs#124
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment