New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow compile_dll to work when source is in tempdir() #531

merged 2 commits into from Jan 12, 2015


None yet
2 participants

richfitz commented Jul 29, 2014

compile_dll() currently fails when package is being built in tempdir()

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 tempdir(), even as a subdirectory. As devtools:::install_min works in tempdir() too, the preclean causes the entire package to be removed.

Undesirable behaviour:

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:

# character(0)

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 tempdir() (created by tempfile()) makes the problem go away, isolating the build from the rest of the temporary directory.


This comment has been minimized.


hadley commented Jul 29, 2014

Makes sense. Could you please also add a bullet to NEWS?

hadley added a commit that referenced this pull request Jan 12, 2015

Merge pull request #531 from richfitz/master
Allow compile_dll to work when source is in tempdir()

@hadley hadley merged commit 09b137d into r-lib:master Jan 12, 2015

1 check passed

continuous-integration/travis-ci The Travis CI build passed

This comment has been minimized.


hadley commented Jan 12, 2015


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment