r-lib / devtools

Tools to make an R developer's life easier
https://devtools.r-lib.org
Other
2.37k stars 753 forks source link

check_mac_release fails to cleanup temp directory #2417

Closed BartJanvanRossum closed 2 years ago

BartJanvanRossum commented 2 years ago

When running check_mac_release, after submitting the tar.gz to macbuilder, there is an error in cleaning up the temp directory.

To replicate is in RStudio: File - New project - New directory - R Package - name the package - Create Project

For this newly created package run check_mac_release. After the package is built and submitted to macbuilder there is an error: Error: [ENOENT] Failed to remove 'C:/Users/***/AppData/Local/Temp/RtmpU9TA4d/test2_0.1.0.tar.gz': no such file or directory

Using RStudio 2022.02.0+443 "Prairie Trillium" Windows 10 R 4.1.3 devtools 2.4.3

ahjota commented 2 years ago

I've reproduced this with

> sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur 11.6.5
[snip]
other attached packages:
[1] devtools_2.4.3 usethis_2.1.3 

If you debug check_mac_release() you'll find the error in the on.exit handler.

on.exit(file_delete(c(built_path, dep_built_paths)), add = TRUE)
> built_path
[1] "/var/folders/zp/0jflmcqn6058v3vctd1t1jxw0000gp/T//RtmpLhiQ1w/samplepackage_0.0.1.tar.gz"
> dep_built_paths
[1] "/var/folders/zp/0jflmcqn6058v3vctd1t1jxw0000gp/T//RtmpLhiQ1w/samplepackage_0.0.1.tar.gz"
> c(built_path, dep_built_paths)
[1] "/var/folders/zp/0jflmcqn6058v3vctd1t1jxw0000gp/T//RtmpLhiQ1w/samplepackage_0.0.1.tar.gz"
[2] "/var/folders/zp/0jflmcqn6058v3vctd1t1jxw0000gp/T//RtmpLhiQ1w/samplepackage_0.0.1.tar.gz"

So the handler tries to delete the same file twice. This could be fixed by using union() rather than c().

> union(built_path, dep_built_paths)
[1] "/var/folders/zp/0jflmcqn6058v3vctd1t1jxw0000gp/T//RtmpLhiQ1w/samplepackage_0.0.1.tar.gz"
hadley commented 2 years ago

Can you please provide a reprex? I can't reproduce this locally and reading the code, I don't see why built_path would end up duplicated in dep_built_path unless you are doing something weird.

BartJanvanRossum commented 2 years ago

I think the fix mentioned in #2416 also fixed this issue. For me, after installing the latest github version of devtools, the error is gone.