Skip to content

write_vc and read_vc don't work outside root-directory in Windows #47

@w-jan

Description

@w-jan

btw: in Linux: this problem doesn't exist
You get this problem in a situation when you want to store data-content outside the source-folder (and this is the workdir).
Many thanks for any help !

Session Info - Session info ------------------------------------------------------------------------------------------------- setting value version R version 3.6.1 (2019-07-05) os Windows 7 x64 SP 1 system x86_64, mingw32 ui RStudio language (EN) collate Dutch_Belgium.1252 ctype Dutch_Belgium.1252 tz Europe/Paris date 2019-08-07
  • Packages -----------------------------------------------------------------------------------------------------
    package * version date lib source
    assertthat 0.2.1 2019-03-21 [1] CRAN (R 3.5.3)
    backports 1.1.4 2019-04-10 [1] CRAN (R 3.5.3)
    callr 3.3.1 2019-07-18 [1] CRAN (R 3.6.1)
    cli 1.1.0 2019-03-19 [1] CRAN (R 3.5.3)
    clipr 0.7.0 2019-07-23 [1] CRAN (R 3.6.1)
    crayon 1.3.4 2017-09-16 [1] CRAN (R 3.5.1)
    desc 1.2.0 2018-05-01 [1] CRAN (R 3.5.1)
    devtools 2.1.0 2019-07-06 [1] CRAN (R 3.6.1)
    digest 0.6.20 2019-07-04 [1] CRAN (R 3.5.3)
    evaluate 0.14 2019-05-28 [1] CRAN (R 3.6.1)
    fortunes 1.5-4 2016-12-29 [1] CRAN (R 3.5.0)
    fs 1.3.1 2019-05-06 [1] CRAN (R 3.5.3)
    git2r 0.26.1 2019-06-29 [1] CRAN (R 3.5.3)
    git2rdata * 0.1 2019-07-15 [1] Github (9233a59)
    glue 1.3.1 2019-03-12 [1] CRAN (R 3.5.3)
    htmltools 0.3.6 2017-04-28 [1] CRAN (R 3.5.3)
    knitr 1.23 2019-05-18 [1] CRAN (R 3.6.1)
    magrittr 1.5 2014-11-22 [1] CRAN (R 3.5.1)
    memoise 1.1.0 2017-04-21 [1] CRAN (R 3.5.1)
    pillar 1.4.2 2019-06-29 [1] CRAN (R 3.5.3)
    pkgbuild 1.0.4 2019-08-05 [1] CRAN (R 3.6.1)
    pkgconfig 2.0.2 2018-08-16 [1] CRAN (R 3.5.3)
    pkgload 1.0.2 2018-10-29 [1] CRAN (R 3.5.3)
    prettyunits 1.0.2 2015-07-13 [1] CRAN (R 3.5.1)
    processx 3.4.1 2019-07-18 [1] CRAN (R 3.6.1)
    ps 1.3.0 2018-12-21 [1] CRAN (R 3.5.3)
    R6 2.4.0 2019-02-14 [1] CRAN (R 3.5.3)
    Rcpp 1.0.1 2019-03-17 [1] CRAN (R 3.5.3)
    remotes 2.1.0 2019-06-24 [1] CRAN (R 3.6.1)
    reprex * 0.3.0 2019-05-16 [1] CRAN (R 3.6.1)
    rlang 0.4.0 2019-06-25 [1] CRAN (R 3.5.3)
    rmarkdown 1.14 2019-07-12 [1] CRAN (R 3.6.1)
    rprojroot 1.3-2 2018-01-03 [1] CRAN (R 3.5.1)
    sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 3.5.3)
    testthat 2.2.1 2019-07-25 [1] CRAN (R 3.6.1)
    tibble 2.1.3 2019-06-06 [1] CRAN (R 3.5.3)
    usethis 1.5.1 2019-07-04 [1] CRAN (R 3.6.1)
    whisker 0.3-2 2013-04-28 [1] CRAN (R 3.5.1)
    withr 2.1.2 2018-03-15 [1] CRAN (R 3.5.1)
    xfun 0.8 2019-06-25 [1] CRAN (R 3.6.1)
    yaml 2.2.0 2018-07-25 [1] CRAN (R 3.5.2)

[1] C:/R/Library
[2] C:/Program Files/R/R-3.6.1/library

library(git2rdata)
x <- seq(1:26)
y <- letters
df <- data.frame(x,y)
#if the file is located in the same folder, then the writing-function works, also if repeated several times
write_vc(df, "df_vc", sorting = c("x"), strict =  FALSE)
#> 1de50dce6d5139f98a8e69d4d45d26ae7d32c64f 
#>                              "df_vc.tsv" 
#> 2e638fa8808a354a460c86349ba4e7414722c808 
#>                              "df_vc.yml"

#e.g. in a subdirectory: no problem: i can execute this function repeatingly
write_vc(df, file.path(".","data","df_vc"), sorting = c("x"), strict =  FALSE)
#> 1de50dce6d5139f98a8e69d4d45d26ae7d32c64f 
#>                         "data/df_vc.tsv" 
#> 2e638fa8808a354a460c86349ba4e7414722c808 
#>                         "data/df_vc.yml"

#the problem arises when I want to save it in a folder outside the root-folder
#the first time, when it's a new file, then it will be saved (but not in reprex where it fails immediately)
write_vc(df, file.path("..","data","df_vc"), sorting = c("x"), strict =  FALSE)
#> Error in value[[3L]](cond): Existing metadata file is invalid.
#> Metadata file missing.
# my comment: 1de50dce6d5139f98a8e69d4d45d26ae7d32c64f 2e638fa8808a354a460c86349ba4e7414722c808 
# my comment: "C:/R/Projecten/Issues/data/df_vc.tsv"   "C:/R/Projecten/Issues/data/df_vc.yml"

#if I want to overwrite the file it fails, even with strict = FALSE
write_vc(df, file.path("..","data","df_vc"), sorting = c("x"), strict =  FALSE)
#> Error in value[[3L]](cond): Existing metadata file is invalid.
#> Metadata file missing.


#if I want to read it, a similar problem
test <- read_vc("df_vc") #works
test <- read_vc(file.path(".","data","df_vc")) #works
test <- read_vc(file.path("..","data","df_vc")) #error
#> Error in value[[3L]](cond): Metadata file missing.

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