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
Dependencies issue #27
Conversation
Stopping if the shared object files are missing is not the best option. Instead, if they are absent, we should try to create them first and then quit if they are still not there. This is what I just did with my most recent commit. Proof of conceptTo construct the shared object, the user must call the
The shared object will not be constructed in this situation. To address this issue, I included another check in the |
I don't understand why the shared object/so file would ever be absent, if the package was installed? Can you clarify / explain what files are created in your rcpp_write_index_outofbound example? Shouldn't there be a shared object created for whatever package that function is defined in? |
To clarify, if a user just wants to analyze a single function rather than the entire package, he may use the Example: suppose a user wants to analyze pkg_path <- "/home/fabri/test/testHarness/RcppDeepState/inst/testpkgs/testSAN"
fun_name <- "rcpp_write_index_outofbound"
deepstate_fun_create(pkg_path, fun_name)
deepstate_fuzz_fun(pkg_path, fun_name)
deepstate_analyze_fun(pkg_path, fun_name) The issue is that, before I implemented the modifications in this pull request, the
The package is installed using |
ok, thanks for the detailed explanation. I think I understand now. Basically, the user may be trying to compile a test harness in a source package which has not yet been installed on the system. The confusing part for me was that R CMD INSTALL is called in this case not actually for its main purpose of installing to the system library, but for its side effect of compiling the cpp files in the src directory, and creating a so file in there. Right? |
Yes, this is correct. Now I'm attempting to figure out why this pull request's CI is failing. It appears to be due to the following error message caused by the function
I tried running the tests locally and they were successful, but using r-lib/actions causes CI to fail with this issue. |
I believe this refers to the following from https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Writing-portable-packages
|
rather than using system("R CMD INSTALL path/to/pkg") I wonder if you could use install.packages("path/to/pkg", repo=NULL) ? or devtools::install("path/to/pkg") ? |
You are correct! Thank you for your help; this resolved the issue. I changed the Regarding the use of if (length(Sys.glob(shared_objects)) <= 0) {
error_msg <- paste("ERROR: the shared object for your package cannot be",
"generated. This is probably caused by a missing",
"dependency. Please install all the dependencies for",
"your package.")
stop(error_msg)
} As discussed during the conversation we had on Tuesday I will ensure that RcppDeepState-action installs the missing package dependencies running As we mentioned on Tuesday, I will make sure that RcppDeepState-action installs any missing package dependencies by executing |
R/fun_makefile_create.R
Outdated
install.packages(package, repo=NULL) | ||
|
||
if (length(Sys.glob(shared_objects)) <= 0) { | ||
error_msg <- paste("ERROR: the shared object for your package cannot be", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you don't need a paste and intermediate error_msg
variable here, instead just use
stop(
"the shared object ",
"for your")
also please remove ERROR: since R adds that automatically, to avoid displaying Error: ERROR: etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
R/fun_makefile_create.R
Outdated
makevars_file <- file.path(package, "src", "Makevars") | ||
if (dir.exists(file.path(package, "src"))) { | ||
makevars_content <- "PKG_CXXFLAGS += -g \n" | ||
write(makevars_content, makevars_file, append=TRUE) | ||
makevars_content <- "PKG_CXXFLAGS += -g \n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there any reason to have a different/non-standard 4 space indent here? if not can you please change back to 2 space indent, which seems conssitent with the surrounding code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My mistake, I updated this portion of code with commit f957075
NAMESPACE
Outdated
import(utils) | ||
import(xml2) | ||
importFrom(utils,unzip) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typically to avoid confusion, you should not use both importFrom(utils,unzip) and import(utils). what other function from utils are you using? Please either add that to the importFrom, or remove the importFrom, keep the import, and add utils:: prefix to the R code from utils, for example utils::unzip
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm using unzip
and install.packages
from utils. If I use import
for utils, I get the following warning:
Warning: replacing previous import ‘Rcpp::prompt’ by ‘utils::prompt’ when loading ‘pkgA’
There is most likely some conflict between utils and Rcpp. Instead, I replaced import
with importFrom
with commit 11eaa1b.
R/fun_makefile_create.R
Outdated
stop("ERROR: the shared object for your package cannot be generated.", | ||
"This is probably caused by a missing dependency. Please install", | ||
"all the dependencies for your package.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
> stop("ERROR: one sentence.", "Another sentence.")
Error: ERROR: one sentence.Another sentence.
please remove ERROR: and use a single argument to stop:
stop("One sentence. Another sentence.")
usually it is preferable to have 80 character max lines, and break lines like you do here, but for long character strings used in messages, it is preferable to not break them over multiple lines, to facilitate translation -- translators would have to translate each string separately. see https://github.com/MichaelChirico/potools for more info
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your detailed explanation; I followed your suggestions and updated this with commit 3ede877.
great! |
R/fun_makefile_create.R
Outdated
compiler_cppflags <- paste(cppflags, collapse=" -I ") | ||
cppflags_write <- paste0("CPPFLAGS=-I",compiler_cppflags) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this logic tested? I thought there was supposed to be no space between -I and the include path?
anyway please remove repetition of -I in this logic. I believe it should be paste(paste0("-I", cppflags), collapse=" ")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! There should be no space between -I
and the include path. I tested this locally and it works, but I'll let CI finish to ensure that everything is working correctly.
Updated with commit 179ac76
compiler_ldflags <- paste0("-L", rinside_lib, " -Wl,-rpath=", rinside_lib) | ||
compiler_ldflags <- paste(compiler_ldflags, "-L${R_LIB} -Wl,-rpath=${R_LIB}") | ||
compiler_ldflags <- paste(compiler_ldflags, paste0("-L", deepstate_build, " -Wl,-rpath=", deepstate_build)) | ||
write_to_file <- paste0(write_to_file, "LDFLAGS=", compiler_ldflags, "\n") | ||
ldflag <- function(path) paste0("-L", path, " -Wl,-rpath=", path) | ||
ldflags <- c(ldflag(rinside_lib), ldflag("${R_LIB}"), ldflag(deepstate_build)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is better! nice cleanup. the intent is much more clear this way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
@tdhock As mentioned during the meeting, I have published a new blog article on the beta testing results. If you agree, I'll merge this pull request as well as FabrizioSandri/RcppDeepState-action#20. |
sounds great please merge! |
Following a conversation with my mentor @tdhock, we determined that RcppDeepState should not execute the
install.packages
function within thedeepstate_create_makefile
method since it is bad practice.Furthermore, running
install.packages
does not install the package dependencies, resulting in the shared object file not being generated. The error message for the hermiter package wasInstead of terminating, RcppDeepState kept running, consequently compiling the
src/*.cpp
with weird include problems. To solve this issue, I replaced the installation command withdevtools::install
and moved it to the action code. Furthermore, I modified the conditions such that if the shared object is not generated, an error is generated and the execution is terminated.Related to:
LinkingTo:
field? RcppDeepState-action#19