Working on a small Rcpp package to use Boost
and some of its geometry functions in C.
Finished writing the functions and everything was working well. Tested that everything was working properly (Clean and Rebuild
and testing the functions) one last time before pushing up to GitHub. Once I double-checked the directory was all cleanly stored in GitHub I removed the directory from my local machine. It should also be noted that I have Roxygen2 running on this and managing the NAMESPACE
file.
Upon cloning the directory back and Clean and Rebuild
I get the following error:
==> Rcpp::compileAttributes()
* Updated R/RcppExports.R
==> R CMD INSTALL --preclean --no-multiarch --with-keep.source MinimumRcpp
* installing to library ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library’
* installing *source* package ‘MinimumRcpp’ ...
clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -g -O2 -c RcppExports.cpp -o RcppExports.o
** libs
clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -g -O2 -c findParetoSet.cpp -o findParetoSet.o
clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Rcpp/include" -I/usr/local/include -fPIC -Wall -g -O2 -c kintersection.cpp -o kintersection.o
clang++ -std=gnu++11 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o MinimumRcpp.so RcppExports.o findParetoSet.o kintersection.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
installing to /Library/Frameworks/R.framework/Versions/3.5/Resources/library/MinimumRcpp/libs
** R
** byte-compile and prepare package for lazy loading
Error in asNamespace(ns) : not a namespace
Error : unable to load R code in package ‘MinimumRcpp’
ERROR: lazy loading failed for package ‘MinimumRcpp’
* removing ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/MinimumRcpp’
Exited with status 1.
Of course, nothing changed in the code. However, I do have the following .gitignore
files:
# /.gitignore
inst/lib
.Rproj.user ## Could this be an issue?
.Rproj.user/ ## Could this be an issue?
.Rproj.user/** ## Could this be an issue?
src/*.o
src/*.so
src/*.dll
src/symbols.rds
.Rhistory
.RData
.DS_Store
## QtCreator
Rcpp.pro
Rcpp.pro.user
*.autosave
.#*
*.tar.gz
vignettes/*_cache
## GNU global
GPATH
GRTAGS
GTAGS
##
local/
## docker helpers
docker/*sh
docker/*/*.sh
# /.Rbuildignore
debian
inst/doc/html
inst/doc/latex
inst/doc/man
inst/doc/jss.bst
vignettes/jss.bst
^.*\.Rproj$
^\.Rproj\.user$
vignettes/notyet
doxyfile
\.travis\.yml
\.dir-locals\.el
\.clang_format
vignettes/getCurrentVersionsOfCitedPackages.R
^Contributing.md$
^\.codecov\.yml$
inst/include/Rcpp.h.new
inst/include/Rcpp.h.old
LICENSE
.*\.tar\.gz$
\.editorconfig
docker
^GPATH
^GRTAGS
^GTAGS
^local
vignettes/Makefile
vignettes/rmd
\.github
Is it possible that some package data that was necessary for building the package was left behind and is causing the current issues?
Any assistance would be appreciated. Additionally, any advice on how to debug this would help as the current output messages are quite nebulous and are leaving me directionless.
Here is the GitHub repo for reproducibility: https://github.com/eduardoRubioG/MinimumRcpp
Rookie mistake, but a serious one:
never ever keep script files in your R/
directory
everything (and we mean everything) in the directory gets sourced (provided it looks like R code, _i.e. end in .R
)
you left a script with a library(MinimumRcpp)
call in there so now your package byte-code compilation wants to source itself --> not a good plan
in short, keep such scripts but put them in e.g. local/
and exclude local/
via .Rbuildignore
.
Plus an important style lesson
rm(list = ls(all = TRUE))
in your codeSo if you do mv R/script.R R/script.R.txt
and rebuild, all is good.
(I get a half-dozen warnings because n
is not a size_t
but compared to one. You may want to cast it earlier.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With