Skip to content

fread with filenames containing spaces returns non-instructive warning and not error #7885

Description

# Minimal reproducible example; please be sure to set verbose=TRUE where possible!

Where a file does not exist and the filename does not contain spaces, the datatable::fread() function errors correctly.

fread(file.path("data_raw", "foobar.csv"))

Error in fread(file.path("data_raw", "foobar.csv")) :
File 'data_raw/foobar.csv' does not exist or is non-readable. getwd()=='C:/projects/'

However, where a file does not exist and the filename does contain spaces, the datatable::fread() function does not error at all; it warns incorrectly.

fread(file.path("data_raw", "foo bar.csv"))

'data_raw' is not recognized as an internal or external command,
operable program or batch file.
Null data.table (0 rows and 0 cols)

This is problematic as any Rmarkdown document proceeds beyond the warning and errors downstream when relying on the null data.table. My expectation would be that an error - not a warning - would be raised.

# Output of sessionInfo()

R version 4.4.1 (2024-06-14 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 26200)

Matrix products: default


locale:
[1] LC_COLLATE=English_United Kingdom.utf8  LC_CTYPE=English_United Kingdom.utf8    LC_MONETARY=English_United Kingdom.utf8 LC_NUMERIC=C                           
[5] LC_TIME=English_United Kingdom.utf8    

time zone: Europe/London
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices datasets  utils     methods   base     

other attached packages:
 [1] RANN_2.6.2         waterfalls_1.1.4   yardstick_1.4.0    caret_7.0-1        lattice_0.22-6     vip_0.4.6          tune_2.1.0         workflows_1.3.0   
 [9] workflowsets_1.1.1 parsnip_1.6.0      themis_1.0.3       recipes_1.3.3      rsample_1.3.2      ggplot2_4.0.0      tidyr_1.3.1        dplyr_1.1.4       
[17] sf_1.0-21          data.table_1.17.8  knitr_1.50        

loaded via a namespace (and not attached):
 [1] tidyselect_1.2.1     timeDate_4052.112    farver_2.1.2         S7_0.2.0             fastmap_1.2.0        pROC_1.19.0.1        digest_0.6.37       
 [8] rpart_4.1.23         timechange_0.3.0     lifecycle_1.0.4      survival_3.6-4       magrittr_2.0.4       compiler_4.4.1       rlang_1.1.6         
[15] tools_4.4.1          yaml_2.3.10          bit_4.6.0            classInt_0.4-11      plyr_1.8.9           DiceDesign_1.10      RColorBrewer_1.1-3  
[22] KernSmooth_2.23-24   withr_3.0.2          purrr_1.2.0          stats4_4.4.1         nnet_7.3-19          grid_4.4.1           e1071_1.7-16        
[29] future_1.68.0        iterators_1.0.14     globals_0.18.0       scales_1.4.0         MASS_7.3-60.2        cli_3.6.5            crayon_1.5.3        
[36] rmarkdown_2.30       generics_0.1.4       rstudioapi_0.17.1    future.apply_1.20.2  tzdb_0.5.0           reshape2_1.4.4       DBI_1.2.3           
[43] proxy_0.4-27         stringr_1.5.2        splines_4.4.1        dials_1.4.4          parallel_4.4.1       vctrs_0.6.5          hardhat_1.4.2       
[50] Matrix_1.7-0         hms_1.1.4            bit64_4.6.0-1        listenv_0.10.0       foreach_1.5.2        gower_1.0.2          units_1.0-0         
[57] glue_1.8.0           parallelly_1.45.1    codetools_0.2-20     stringi_1.8.7        lubridate_1.9.4      gtable_0.3.6         ROSE_0.0-4          
[64] tibble_3.3.0         furrr_0.3.1          pillar_1.11.1        htmltools_0.5.8.1    ipred_0.9-15         lava_1.9.2           R6_2.6.1            
[71] vroom_1.6.6          evaluate_1.0.5       readr_2.1.5          renv_0.14.0          class_7.3-22         Rcpp_1.1.2           nlme_3.1-164        
[78] prodlim_2026.03.11   xfun_0.53            ModelMetrics_1.2.2.2 pkgconfig_2.0.3     

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions