Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Allow compile_dll to work when source is in tempdir() #531
I'm not sure how common this use case is, but the fix is simple enough. The reproducible example seems contrived but I have a workflow that is basically doing this.
To trigger: try to build a package that needs compilation in the directory given by
path <- tempdir() file.copy(system.file("tests/testthat/testDllRcpp", package="devtools"), path, recursive=TRUE) pkg <- file.path(path, "testDllRcpp") dir(pkg) # package ready to be built/etc. # This line will cause an error: devtools::load_all(pkg) # or devtools::document(), etc # Loading testDllRcpp # Re-compiling testDllRcpp # '/Library/Frameworks/R.framework/Resources/bin/R' --vanilla CMD INSTALL \ # '/private/var/folders/dm/6q6zdvzj0154h96p80vl15lc0000gn/T/RtmptdiZ58/testDllRcpp' \ # --library='/var/folders/dm/6q6zdvzj0154h96p80vl15lc0000gn/T//RtmptdiZ58' \ # --no-R --no-data --no-help --no-demo --no-inst --no-docs --no-exec \ # --no-multiarch --no-test-load --preclean # # ERROR: cannot install to srcdir for package ‘testDllRcpp’ # * removing ‘/private/var/folders/dm/6q6zdvzj0154h96p80vl15lc0000gn/T/RtmptdiZ58/testDllRcpp’ # Error: Command failed (1)
The directory is now empty:
I didn't dig down into exactly how this is happening, but the clean seems to be the culprit.
Changing the line
install_min(pkg, tempdir(), components = "libs",
to point at a subdirectory of