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

fs::dir_ls("C:") returns Error: [EBUSY] Failed to stat 'C:/hiberfil.sys': resource busy or locked #121

Closed
vnijs opened this Issue Jul 12, 2018 · 11 comments

Comments

Projects
None yet
2 participants
@vnijs
Copy link

vnijs commented Jul 12, 2018

I'm using shinyFiles as a (server-side) file-browser for shiny apps. Works great on Mac, Linux, Rstudio-desktop, and Rstudio-server but ... Windows causes some problems. e.g., directories with non-latin characters (e.g., папка) are translated fo "?????" which is not great (see example below). It seems fs can deal with these types of issues much better but I'm hitting some snags there as well. list.files("C:") has only one problems (note the ???? directory) but fs::dir_ls("C:") only returns an error.

Is there a work around you can suggest @jimhester? Thanks.

Example

> list.files("C:")
 [1] "$Recycle.Bin"                   "$WINRE_BACKUP_PARTITION.MARKER" "?????"                          "bootmgr"                        "BOOTNXT"                       
 [6] "diamonds_pivot.csv"             "Documents and Settings"         "hiberfil.sys"                   "pagefile.sys"                   "PerfLogs"                      
[11] "Program Files"                  "Program Files (x86)"            "ProgramData"                    "R"                              "Recovery"                      
[16] "Rtools"                         "swapfile.sys"                   "System Volume Information"      "Users"                          "Windows"                       
> fs::dir_ls("C:")
Error: [EBUSY] Failed to stat 'C:/hiberfil.sys': resource busy or locked

If I try to eliminate the .sys files I get:

fs::dir_ls("C:", regex = "[^(\\.sys)]$")
Error: [EPERM] Failed to stat 'C:/System Volume Information': operation not permitted
@jimhester

This comment has been minimized.

Copy link
Member

jimhester commented Jul 12, 2018

The errors are coming when trying to colorize the paths for display, which you can disable by setting Sys.setenv(LS_COLORS = "")

@vnijs

This comment has been minimized.

Copy link
Author

vnijs commented Jul 12, 2018

Hmmmm.

> Sys.setenv(LS_COLORS = "")
> fs::dir_ls("C:")
Error: [EBUSY] Failed to stat 'C:/hiberfil.sys': resource busy or locked
> devtools::session_info()
Session info -------------------------------------------------------------------------------------------
 setting  value                       
 version  R version 3.5.1 (2018-07-02)
 system   x86_64, mingw32             
 ui       RStudio (1.2.679)           
 language (EN)                        
 collate  English_United States.1252  
 tz       America/Los_Angeles         
 date     2018-07-12                  

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.0)
 digest       0.6.15     2018-01-28 CRAN (R 3.5.0)
 fs           1.2.3      2018-06-08 CRAN (R 3.5.1)
 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.0)
 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 17, 2018

Any additional suggestions @jimhester since Sys.setenv(LS_COLORS = "") doesn't' seem to do the trick? Am I missing something?

@jimhester jimhester closed this in dc74b70 Jul 17, 2018

@jimhester

This comment has been minimized.

Copy link
Member

jimhester commented Jul 17, 2018

Should now be fixed.

@vnijs

This comment has been minimized.

Copy link
Author

vnijs commented Jul 18, 2018

I'm having trouble building the package on Windows. I tried using `devtools::build_win(version = "R-release") but that gives similar error messages (see link below). Any suggestions?

https://win-builder.r-project.org/Agct9Q7ZP1NV/00install.out

==> Rcmd.exe INSTALL --no-multiarch --with-keep.source fs

* installing to library 'C:/R/R-3.5.1/library'
* installing *source* package 'fs' ...
** libs
c:/Rtools/mingw_64/bin/g++ -shared -s -static-libgcc -o fs.dll tmp.def error.o utils.o link.o path.o dir.o file.o fs.o id.o windows/getmode.o RcppExports.o ./libuv/libuv.a -lpthread -lws2_32 -lkernel32 -lpsapi -liphlpapi -lshell32 -luserenv -LC:/R/R-35~1.1/bin/x64 -lR
C:\Rtools\mingw_64\bin\nm.exe: error.o: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: utils.o: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: link.o: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: path.o: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: dir.o: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: file.o: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: fs.o: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: id.o: File format not recognized
C:\Rtools\mingw_64\bin\nm.exe: RcppExports.o: File format not recognized
error.o: file not recognized: File format not recognized
collect2.exe: error: ld returned 1 exit status
no DLL was created
ERROR: compilation failed for package 'fs'
* removing 'C:/R/R-3.5.1/library/fs'
* restoring previous 'C:/R/R-3.5.1/library/fs'
In R CMD INSTALL

Exited with status 1.
@jimhester

This comment has been minimized.

Copy link
Member

jimhester commented Jul 18, 2018

It looks like you have stale object files in your src directory, try deleting them and trying again.

@vnijs

This comment has been minimized.

Copy link
Author

vnijs commented Jul 18, 2018

Works great now. Thanks @jimhester!

@vnijs

This comment has been minimized.

Copy link
Author

vnijs commented Jul 20, 2018

It seems I spoke somewhat too soon. fs::dir_ls works fine, but I'm having similar problems with fs::file_info and fs::dir_info (see below).

> Sys.setenv(LS_COLORS = "")
> files <- fs::dir_ls("C:/")
> fs::file_info(files)
Error: [EBUSY] Failed to stat 'C:/hiberfil.sys': resource busy or locked
> fs::dir_info("C:/")
Error: [EBUSY] Failed to stat 'C:/hiberfil.sys': resource busy or locked
@vnijs

This comment has been minimized.

Copy link
Author

vnijs commented Jul 21, 2018

I expect this is related as well:

> file.exists("C:/PerfLogs")
[1] TRUE
> fs::file_exists("C:/PerfLogs")
Error: [EPERM] Failed to stat 'C:/PerfLogs': operation not permitted
@jimhester

This comment has been minimized.

Copy link
Member

jimhester commented Jul 23, 2018

Those are all expected, if you can't stat those files than you can't retrieve information about them.

@vnijs

This comment has been minimized.

Copy link
Author

vnijs commented Jul 23, 2018

Even for fs::file_exists? It seems that fs::file_access("C:/PerfLogs", "exists") does work but fs::file_exists("C:/PerfLogs") does not. Can you explain why file.exist does work then?

The issue with fs::file_info(files) and `fs::dir_info("C:/") is that it doesn't return any information at all due to an error with one (or a few) files. Is there an example you could point to perhaps on how to best return a tibble with results for those files for which results are possible?

jimhester added a commit that referenced this issue Jul 23, 2018

@vnijs vnijs referenced this issue Jul 24, 2018

Closed

handling errors? #105

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment