r drake file paths on windows messed up

79 Views Asked by At

I was trying to run a project with drake. The make(plan) runs through fine but after the the last point of the plan I receive an error.

Error in file(private$total_file, "r+w") : cannot open connection
Additional Warning:
In file(private$total_file, "r+w") :
'C:\R_project\.drake/drake/history/total' cannot open file: Invalid argument

I am running on a windows system (with \\ path separators). Typically R uses the / path convention and handles this fine. But somehow the paths are messed up here and I do not know why.

Is this known and a workaround available? Does someone know where the error is produced, so I can fix it in the drake code?

Thank you!

Example code:

plan2 = drake_plan(
  loadRequirements =   {
    library(ggplot2)
  }
)
vis_drake_graph(plan2)
make(plan2)

Output of traceback()

> traceback()
20: file(private$total_file, "r+w")
19: private$txtq_inc_total(length(out))
18: private$txtq_push(title = title, message = message)
17: force(code)
16: private$txtq_exclusive(private$txtq_push(title = title, message = message))
15: config$cache$history$push(title = target, message = meta_hash)
14: store_meta(target = target, value = value, meta = meta, hash = hash, 
        config = config)
13: store_item(target = target, value = value, meta = meta, config = config)
12: store_outputs(target = target, value = value, meta = meta, config = config)
11: conclude_build_impl.default(value, target, meta, config)
10: conclude_build_impl(value, target, meta, config)
9: conclude_build(build, config)
8: local_build(target = targets[1], config = config, downstream = targets[-1])
7: loop_check(config)
6: drake_backend_loop(config)
5: drake_backend(config)
4: run_backend(config)
3: process_targets(config)
2: make_impl(config)
1: make(plan)
1

There are 1 best solutions below

1
On BEST ANSWER

On my Windows 10 machine, your example runs without error. Maybe you are using old versions of drake and txtq. If so, you can upgrade them with install.packages(). Otherwise, make() with history = FALSE should avoid the issue.

library(drake)
plan <- drake_plan(
  loadRequirements = {
    library(ggplot2)
  }
)
vis_drake_graph(plan)

make(plan)
#> i Consider drake::r_make() to improve robustness.
#> > target loadRequirements

Created on 2020-07-28 by the reprex package (v0.3.0)

Session info
sessionInfo()
#> R version 4.0.2 (2020-06-22)
#> Platform: x86_64-w64-mingw32/x64 (64-bit)
#> Running under: Windows 10 x64 (build 18363)
#> 
#> Matrix products: default
#> 
#> locale:
#> [1] LC_COLLATE=English_United States.1252 
#> [2] LC_CTYPE=English_United States.1252   
#> [3] LC_MONETARY=English_United States.1252
#> [4] LC_NUMERIC=C                          
#> [5] LC_TIME=English_United States.1252    
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] ggplot2_3.3.2 drake_7.12.4 
#> 
#> loaded via a namespace (and not attached):
#>  [1] storr_1.2.1       progress_1.2.2    tidyselect_1.1.0  xfun_0.16        
#>  [5] purrr_0.3.4       colorspace_1.4-1  vctrs_0.3.2       generics_0.0.2   
#>  [9] htmltools_0.5.0   yaml_2.2.1        rlang_0.4.7       pillar_1.4.6     
#> [13] txtq_0.2.3        glue_1.4.1        withr_2.2.0       lifecycle_0.2.0  
#> [17] stringr_1.4.0     munsell_0.5.0     gtable_0.3.0      visNetwork_2.0.9 
#> [21] htmlwidgets_1.5.1 evaluate_0.14     knitr_1.29        callr_3.4.3      
#> [25] ps_1.3.3          curl_4.3          parallel_4.0.2    fansi_0.4.1      
#> [29] highr_0.8         Rcpp_1.0.5        backports_1.1.8   scales_1.1.1     
#> [33] filelock_1.0.2    webshot_0.5.2     jsonlite_1.7.0    mime_0.9         
#> [37] hms_0.5.3         digest_0.6.25     stringi_1.4.6     processx_3.4.3   
#> [41] dplyr_1.0.0       grid_4.0.2        cli_2.0.2         tools_4.0.2      
#> [45] magrittr_1.5      base64url_1.4     tibble_3.0.3      crayon_1.3.4     
#> [49] pkgconfig_2.0.3   ellipsis_0.3.1    xml2_1.3.2        prettyunits_1.1.1
#> [53] lubridate_1.7.9   httr_1.4.2        assertthat_0.2.1  rmarkdown_2.3    
#> [57] R6_2.4.1          igraph_1.2.5      compiler_4.0.2