-
Notifications
You must be signed in to change notification settings - Fork 38
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
Error in get_pkg_srcrefs(pkg) : Unexpected format for source refs. #134
Comments
I was getting this same message. It happened when I was using devtools::load_all(".") while building a package. This makes sense because the package I was working on was not in sync with the most recently built version. When I properly built the package (install and restart under build menu in RStudio), the error was resolved. Perhaps profvis could somehow check to be sure that loaded version is that same as the most recent build and throw a friendlier error? |
This *appears* correct. I tested it by inspection with the SUGG and CRAM data on a set seed in CV. I think I *could* set up a test for this, but it'd be a lot of work, a time-consuming test, and amount to repeatedly re-doing said test-by-inspection. As it is, this memoization looks like it cuts the run time of CV down to a quarter of what it was. refs: https://memoise.r-lib.org/reference/memoise.html#details https://rdrr.io/r/base/ns-hooks.html r-lib/profvis#134 r-lib/memoise#79 (comment)
I haven't seen this problem for a while, so I'm going to assume it's fixed. Please let me know if you see it again and I'll investigate further. |
@hadley I still see this problem when a package contains a function created using Below is a MRE:
usethis::create_package("profvis.test")
writeLines(
"check_same_len <- function(x, y) {
if (NROW(x) == NROW(y)) TRUE else \"Must have same length\"
}
test_same_len <- checkmate::makeTestFunction(check_same_len)"
,
"R/check.R"
)
devtools::load_all()
profvis::profvis(test_same_len(mtcars, mtcars))
#> Error in get_pkg_srcrefs(pkg) : Unexpected format for source refs. Digging a little bit deeper, I found that this error is caused by Line 113 in dec7381
[[1]]
{
[[2]]
isTRUE(check_same_len(x, y)) Thus |
Thanks for the reprex, but it works for me 😞 (once I add a |
What version of R are you using? Does it reproduce for you with this simpler test case? check_same_len <- function(x, y) {
if (NROW(x) == NROW(y)) TRUE else "Must have same length"
}
test_same_len <- checkmate::makeTestFunction(check_same_len)
profvis::profvis(test_same_len(mtcars, mtcars)) It's possible due to the line |
I'm using R 4.4.0. You are right. The Interesting. It also works fine for me inside R scripts. This error only occurs when using makeTestFunction inside a package and loading it using devtools. |
@hongyuanjia, this is consistent with the behavior I experienced, described in my May 10, 2022 post. I only experienced the error when using devtools to load a package during development. When I built the package, without modifying the code, and loaded the package, profvis worked just fine |
I'm getting an error when I try to profile code with RStudio (following this tutorial).
Here's a reprex:
Thanks!
The text was updated successfully, but these errors were encountered: