gesistsa / rio

🐟 A Swiss-Army Knife for Data I/O
http://gesistsa.github.io/rio/
600 stars 76 forks source link

Investigate the warning emitted by `test_export_list.R:19:9` #438

Closed chainsawriot closed 3 months ago

chainsawriot commented 3 months ago

Which also got emitted on CI. And actually, the expected file is not created.

chainsawriot commented 3 months ago

This works with the current CRAN version 1.1.1

withr::with_tempdir({
    mylist <- list(
        mtcars3 = mtcars[1:10, ],
        mtcars2 = mtcars[11:20, ],
        mtcars1 = mtcars[21:32, ]
    )
    rio::export_list(mylist, file = paste0("file_", 1:3, ".csv"), archive = "arch/archive.zip")
    file.exists("arch/archive.zip")
})

But not with HEAD

chainsawriot commented 3 months ago

By adding back these two lines to HEAD, this test works.

1f2cfe8c4d7e92cb3432904d3b7bb2ee10b20138

chainsawriot commented 3 months ago

https://github.com/gesistsa/rio/pull/434#issuecomment-2220474755

As it turns out, that setwd() call is important for exporting compressed file to a relative path, e.g. arch/archive.zip and we can't do that on.exit. b/c that copy operation depends on where the current working directory is.

https://github.com/gesistsa/rio/blob/b79130e4c1091a7c7cab65b6bf5d41a7626396e9/R/compression.R#L50-L67

Is there a better way to handle this? And #319 is still a hanging problem.

chainsawriot commented 3 months ago

Until a better solution is derived for #319 , I will add back that setwd(). Please continue the discussion about possible solution in #319.