remotes
remotes copied to clipboard
Copying to build directory fails with devtools::check - over-long path during file.copy
Hi, I'm getting the below errors when building a package.
The directory I'm installing to is <30 characters, and my tempdir() directory is also <40 (I'm assuming this is what would normally get used for temporary file copying). I've also enabled long file paths in the windows registry... but no luck.
Other members of my team can build an identical version of this package without any issues.
The output of .Last.error.trace is truncating (per the ... in the output below), so I'm having trouble figuring out how to start troubleshooting. Any suggestions would be really appreciated - thanks.
sessionInfo:
R version 4.1.2 (2021-11-01)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22000)
devtools_2.4.3
Output of build:
Warning in file.copy(pkgname, Tdir, recursive = TRUE, copy.date = TRUE) :
over-long path
Warning in file.copy(pkgname, Tdir, recursive = TRUE, copy.date = TRUE) :
over-long path
Warning in file.copy(pkgname, Tdir, recursive = TRUE, copy.date = TRUE) :
over-long path
Warning in file.copy(pkgname, Tdir, recursive = TRUE, copy.date = TRUE) :
over-long path
Warning in file.copy(pkgname, Tdir, recursive = TRUE, copy.date = TRUE) :
over-long path
Warning in file.copy(pkgname, Tdir, recursive = TRUE, copy.date = TRUE) :
over-long path
Warning in file.copy(pkgname, Tdir, recursive = TRUE, copy.date = TRUE) :
over-long path
Warning in file.copy(pkgname, Tdir, recursive = TRUE, copy.date = TRUE) :
over-long path
Warning in file.copy(pkgname, Tdir, recursive = TRUE, copy.date = TRUE) :
over-long path
Warning in file.copy(pkgname, Tdir, recursive = TRUE, copy.date = TRUE) :
over-long path
ERROR
copying to build directory failed
Error in (function (command = NULL, args = character(), error_on_status = TRUE, :
System command 'Rcmd.exe' failed, exit status: 1, stdout & stderr were printed
Type .Last.error.trace to see where the error occurred
output of .Last.error.trace:
Stack trace:
1. base:::source("c:\\dev\\r\\packages\\ausmodels\\dev\\scripts\\build_ausmodels.R", ...
2. base:::withVisible(eval(ei, envir))
3. base:::eval(ei, envir)
4. base:::eval(ei, envir)
5. devtools:::check()
c:/dev/r/packages/ausmodels/dev/scripts/build_ausmodels.R:46:1 ...
6. withr::with_envvar(pkgbuild::compiler_flags(FALSE), action = "prefix", ...
7. base:::force(code)
8. pkgbuild::build(pkg$path, tempdir(), args = build_args, quiet = quiet, ...
9. withr::with_temp_libpaths(rcmd_build_tools(options$cmd, c(options$path, ...
10. base:::force(code)
11. pkgbuild:::rcmd_build_tools(options$cmd, c(options$path, options$args), ...
12. pkgbuild:::with_build_tools({ ...
13. withr::with_path(rtools_path(), code)
14. base:::force(code)
15. base:::withCallingHandlers(callr::rcmd_safe(..., env = env, spinner = FALSE, ...
16. callr::rcmd_safe(..., env = env, spinner = FALSE, show = FALSE, ...
17. callr:::run_r(options)
18. base:::with(options, with_envvar(env, do.call(processx::run, ...
19. base:::with.default(options, with_envvar(env, do.call(processx::run, ...
20. base:::eval(substitute(expr), data, enclos = parent.frame())
21. base:::eval(substitute(expr), data, enclos = parent.frame())
22. callr:::with_envvar(env, do.call(processx::run, c(list(bin, args = real_cmdargs, ...
23. base:::force(code)
24. base:::do.call(processx::run, c(list(bin, args = real_cmdargs, ...
25. (function (command = NULL, args = character(), error_on_status = TRUE, ...
26. base:::throw(new_process_error(res, call = sys.call(), echo = echo, ...
x System command 'Rcmd.exe' failed, exit status: 1, stdout & stderr were printed
You can skip the build stage, that is usually not a problem.
You can also set R_REMOTES_STANDALONE="true" (https://github.com/r-lib/remotes#standalone-mode), and then remotes does not use pkgbuild.
If it still fails, then try to debug it to see which paths are causing problems.
Thanks for the suggestions. In response:
- skipping the build stage is not an option for my organisation
- Setting standalone mode didn't help
- I spent most of the day trying to debug to find the paths causing problems, but really struggled... so switched to a different approach as described below
Ultimately I fixed the the problem by deleting my TMP and TEMP environmental variables (both set to C:\Users\MyUserName\AppData\Local\Temp). This made R CMD Build revert to using C:/Windows/Temp, and this worked for me. The R CMD Build documentation says temp dirs should use forward slashes, which mine didn't, so perhaps that was the problem.
I wonder if this is an issue with some kind of change that came along with Windows 11 - this is the only difference I can think of between myself (couldn't build) and my co-workers (could build). Although their TMP and TEMP variables use the same setting.
It doesn't seem like we can reasonably well fix this in remotes, so I am going to close this now. Hopefully the situation is better with newer R versions.