Skip to content
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

Fail to build/document after usethis::use_rcpp() with empty src/ #720

Closed
maurolepore opened this issue Apr 19, 2019 · 4 comments
Closed

Fail to build/document after usethis::use_rcpp() with empty src/ #720

maurolepore opened this issue Apr 19, 2019 · 4 comments
Labels

Comments

@maurolepore
Copy link
Contributor

@maurolepore maurolepore commented Apr 19, 2019

The sequence usethis::use_rcpp(), then "Clean and Rebuild", then devtools::document() fails with

Error in getDLLRegisteredRoutines.DLLInfo(dll, addNames = FALSE) :  must specify DLL via aDLLInfoobject. See getLoadedDLLs()

apparently, because "src/" contains no "file.cpp".

I expected this to work, maybe by automatically adding a src/toy-file.cpp. Or I expected a message with the following TODO items:

  • Add at least one .cpp file into src/
  • Clean and Reload
  • devtools::document()

Below is a sequence starting from a fresh package, leading to the problem, then solving it.

Details
# On a separate sassion
usethis::create_package("~/abc")

# New session
usethis::use_package_doc()
usethis::use_roxygen_md()
usethis::use_rcpp()

R/abc-package.R now looks like this:

#' @keywords internal
"_PACKAGE"

# The following block is used by usethis to automatically manage
# roxygen namespace tags. Modify with care!
## usethis namespace: start
#' @useDynLib abc, .registration = TRUE
#' @importFrom Rcpp sourceCpp
## usethis namespace: end
NULL

Problem

devtools::document()
Updating abc documentation
Writing NAMESPACE
Loading abc
Error in getDLLRegisteredRoutines.DLLInfo(dll, addNames = FALSE) : 
  must specify DLL via aDLLInfoobject. See getLoadedDLLs()
Call `rlang::last_error()` to see a backtrace

Clean and Rebuild also fails

Solution

usethis::use_rcpp("toy")

Now I can 'Clean and Rebuild'

And I can also document

devtools::document()
Updating abc documentation
Loading abc
Writing abc-package.Rd

Info

sessioninfo::session_info()
#> - Session info ----------------------------------------------------------
#>  setting  value                       
#>  version  R version 3.5.3 (2019-03-11)
#>  os       Windows 10 x64              
#>  system   x86_64, mingw32             
#>  ui       RTerm                       
#>  language (EN)                        
#>  collate  English_United States.1252  
#>  ctype    English_United States.1252  
#>  tz       America/New_York            
#>  date     2019-04-19                  
#> 
#> - Packages --------------------------------------------------------------
#>  package     * version date       lib source        
#>  assertthat    0.2.1   2019-03-21 [1] CRAN (R 3.5.3)
#>  cli           1.1.0   2019-03-19 [1] CRAN (R 3.5.3)
#>  crayon        1.3.4   2017-09-16 [1] CRAN (R 3.5.2)
#>  digest        0.6.18  2018-10-10 [1] CRAN (R 3.5.2)
#>  evaluate      0.13    2019-02-12 [1] CRAN (R 3.5.2)
#>  highr         0.8     2019-03-20 [1] CRAN (R 3.5.3)
#>  htmltools     0.3.6   2017-04-28 [1] CRAN (R 3.5.2)
#>  knitr         1.22    2019-03-08 [1] CRAN (R 3.5.2)
#>  magrittr      1.5     2014-11-22 [1] CRAN (R 3.5.2)
#>  Rcpp          1.0.1   2019-03-17 [1] CRAN (R 3.5.3)
#>  rmarkdown     1.12    2019-03-14 [1] CRAN (R 3.5.2)
#>  sessioninfo   1.1.1   2018-11-05 [1] CRAN (R 3.5.2)
#>  stringi       1.4.3   2019-03-12 [1] CRAN (R 3.5.3)
#>  stringr       1.4.0   2019-02-10 [1] CRAN (R 3.5.2)
#>  withr         2.1.2   2018-03-15 [1] CRAN (R 3.5.2)
#>  xfun          0.6     2019-04-02 [1] CRAN (R 3.5.3)
#>  yaml          2.2.0   2018-07-25 [1] CRAN (R 3.5.2)
#> 
#> [1] C:/Users/LeporeM/Documents/R/win-library/3.5
#> [2] C:/Users/LeporeM/Documents/R/R-3.5.3/library

Created on 2019-04-19 by the reprex package (v0.2.1)

@jennybc
Copy link
Member

@jennybc jennybc commented Jul 3, 2019

@coatless Thoughts?

@jennybc jennybc added the feature label Jul 3, 2019
@coatless
Copy link
Contributor

@coatless coatless commented Jul 3, 2019

@jennybc two parts:

  1. Add documentation that emphasizes a c/cpp file must be present in src/
  2. Insert a skeletal C++ file for compilation

I'll probably send a PR tomorrow if that sounds okay?

@jennybc
Copy link
Member

@jennybc jennybc commented Jul 3, 2019

Sure. I'm grooming issues to identify things that are good for tidyverse dev day. My assessment is that this better left to others. Like you. Agree?

@coatless
Copy link
Contributor

@coatless coatless commented Jul 3, 2019

@jennybc 💯

@jennybc jennybc closed this in #860 Sep 11, 2019
jennybc added a commit that referenced this issue Sep 11, 2019
* Add a check to verify the directory has files.

Refactor existing check_directory_is_empty() to use new method.

* Create a new templated helper for the source file examples

Note: This can be extended into the use_r() files as well as they use the same scheme for creating new files.

* Switch to the templated source helper

* Update documentation

* Add a news bulletin

* Don't negate the result.

* Make parallel with use_rcpp(); better message if check fails

* Rename to suggest it returns logical

* Style

* Default to NULL

* Only open if interactive

* Work on docs

* Edit NEWS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

3 participants