r-lib / downlit

Syntax Highlighting and Automatic Linking
https://downlit.r-lib.org
Other
90 stars 22 forks source link

Error with pkgdown that I think is comming from downlit #166

Closed jsilve24 closed 1 year ago

jsilve24 commented 1 year ago

Sorry for cross posting (see https://github.com/r-lib/pkgdown/issues/2186) where I added a comment onto someone elses issue. I am opening a new issue here because I think that error is actually comming from downlit.

In brief, I am running into some very unhelpful error messages when trying to build a pkgdown site which I realized was occuring whenever pkgdown was trying to parse a .Rd file with an examples section. Removing the examples allowed the site to build. Also the backtrace pointed to a downlit call. Here is the reproducible example I provided in the other issue.

Here is (what I think should be) a reproducible example.

git clone https://github.com/jsilve24/fido.git
git checkout develop
R

then in R

pkgdown::clean_site()
pkgdown::build_site()

I have been stuck on this for the past 2 hours. I keep getting this error.

> pkgdown::clean_site()
> pkgdown::build_site()
-- Installing package into temporary library -----------------------------------
== Building pkgdown site =======================================================
Reading from: '/home/jds6696/Dropbox/Research/src/fido'
Writing to:   '/home/jds6696/Dropbox/Research/src/fido/docs'
-- Initialising site -----------------------------------------------------------
Copying '../../../../R/x86_64-pc-linux-gnu-library/4.2/pkgdown/BS5/assets/link.svg' to 'link.svg'
Copying '../../../../R/x86_64-pc-linux-gnu-library/4.2/pkgdown/BS5/assets/pkgdown.js' to 'pkgdown.js'
-
Warning message:
In utils::install.packages(pkg$src_path, repos = NULL, type = "source",  :
  installation of package ‘/home/jds6696/Dropbox/Research/src/fido’ had non-zero exit status
> pkgdown::build_site()
-- Installing package into temporary library -----------------------------------
== Building pkgdown site =======================================================
Reading from: '/home/jds6696/Dropbox/Research/src/fido'
Writing to:   '/home/jds6696/Dropbox/Research/src/fido/docs'
-- Initialising site -----------------------------------------------------------
-- Building home ---------------------------------------------------------------
Writing 'authors.html'
Writing '404.html'
-- Building function reference -------------------------------------------------
Writing 'reference/index.html'
Reading 'man/Y.Rd'
Writing 'reference/Y.html'
Reading 'man/access_dims.Rd'
Writing 'reference/access_dims.html'
Reading 'man/alr.Rd'
Writing 'reference/alr.html'
Reading 'man/alrInv.Rd'
Writing 'reference/alrInv.html'
Reading 'man/alrInv_array.Rd'
Writing 'reference/alrInv_array.html'
Reading 'man/alr_array.Rd'
Writing 'reference/alr_array.html'
Reading 'man/as.list.orthusfit.Rd'
Writing 'reference/as.list.orthusfit.html'
Reading 'man/as.list.pibblefit.Rd'
Writing 'reference/as.list.pibblefit.html'
Reading 'man/as.orthusfit.Rd'
Writing 'reference/as.orthusfit.html'
Reading 'man/as.pibblefit.Rd'
Writing 'reference/as.pibblefit.html'
Reading 'man/basset_fit.Rd'
Writing 'reference/basset_fit.html'
Reading 'man/check_dims.Rd'
Error: 
! in callr subprocess.
Caused by error in `purrr::map(topics, build_reference_topic, pkg = pkg, lazy = lazy, …`:
! In index: 12.
ℹ See `$stdout` for standard output.
Type .Last.error to see the more details.

The error goes away when I remove the @examples section of every one of my functions. Adding \dontrun{} doesnot make a difference. I think the bug is comming up from one of the dependencies downlit but I am not sure.

Here is the .Last.error

Backtrace:
1. pkgdown::build_site()
2. pkgdown:::build_site_external(pkg = pkg, examples = examples, run_dont_run = run_dont_run, …
3. callr::r(function(..., cli_colors, pkgdown_internet) { …
4. callr:::get_result(output = out, options)
5. callr:::throw(callr_remote_error(remerr, output), parent = fix_msg(remerr[[3]]))
---
Subprocess backtrace:
 1. pkgdown::build_site(...)
 2. pkgdown:::build_site_local(pkg = pkg, examples = examples, run_dont_run = run_dont_run, …
 3. pkgdown::build_reference(pkg, lazy = lazy, examples = examples, run_dont_run = run_dont_run, …
 4. purrr::map(topics, build_reference_topic, pkg = pkg, lazy = lazy, …
 5. purrr:::map_("list", .x, .f, ..., .progress = .progress)
 6. purrr:::with_indexed_errors(i = i, error_call = .purrr_error_call, .Call(map_impl, …
 7. base::withCallingHandlers(expr, error = function(cnd) { …
 8. local .f(.x[[i]], ...)
 9. base::withCallingHandlers(data_reference_topic(topic, pkg, examples_env = examples_env, …
10. pkgdown:::data_reference_topic(topic, pkg, examples_env = examples_env, …
11. pkgdown:::run_examples(tags$tag_examples[[1]], env = if (is.null(examples_env)) NULL else new.env(paren…
12. pkgdown:::highlight_examples(code, topic, env = env)
13. downlit::evaluate_and_highlight(code, fig_save = fig_save_topic, …
14. evaluate::evaluate(code, child_env(env), new_device = TRUE, output_handler = output_handler)
15. grDevices::dev.new()
16. base::do.call(dev, a)
17. (function (...) …
18. base::loadNamespace(x)
19. base::library.dynam(lib, package, package.lib)
20. base::dyn.load(file, DLLpath = DLLpath, ...)
21. base::.handleSimpleError(function (err) …
22. local h(simpleError(msg, call))
23. rlang::abort(msg, parent = err)
24. | rlang:::signal_abort(cnd, .file)
25. | base::signalCondition(cnd)
26. (function (cnd) …
27. cli::cli_abort(c(i = "In index: {i}."), parent = cnd, call = error_call)
28. | rlang::abort(message, ..., call = call, use_cli_format = TRUE, …
29. | rlang:::signal_abort(cnd, .file)
30. | base::signalCondition(cnd)
31. global (function (e) …
> 

Also note I think this may be related to https://github.com/r-lib/downlit/issues/85

maelle commented 1 year ago

Could you please try making a reprex (a smaller package)? See https://pkgdown.r-lib.org/CONTRIBUTING.html

I cloned https://github.com/jsilve24/fido and was able to build the website.

stefanoborini commented 1 year ago

@maelle people are not going to go crazy trying to come up with a simple example, especially when they don't know the underlying code, or the nature of the issue, or are unwilling to spend days trying to figure it out. They give you a bug report, a backtrace, and it's up to you as the author of the code to try to understand what's the nature of the problem knowing the content of the backtrace together with your knowledge of the code.

The R community spends way too much time asking for these reproducibile examples, time that would be better spent by looking at your code and try to figure it out.

hadley commented 1 year ago

@stefanoborini As we have told you before, we only have a limited amount of development time, and we'd prefer to spend it fixing bugs that are possible for us to reproduce so that we know when we have fixed them.

dmurdoch commented 1 year ago

@stefanoborini : Besides what @hadley said, many people are willing to put an effort into solving problems that affect them. If you aren't, then your problems probably aren't going to be solved as quickly. Maybe you think the authors of the free software you are using owe you more of their time, but they actually don't owe you anything: the reverse is much more likely to be true.

stefanoborini commented 1 year ago

@dmurdoch all this open stuff helps and is supported by a company that makes money out of a niche of R software and tools. You claim it's free stuff, but we pay for it. If you have limited development time, then hire more. These tools form the backbone of a de-facto monopoly that Rstudio created. Keeping them as opensource does not exonerate them to consider this code as part of their product line.

gaborcsardi commented 1 year ago

@jsilve24 The grDevices::dev.new() call fails for you. IDK how the default device is selected, but you can debug this:

debug(grDevices::dev.new)
pkgdown::build_site(new_process = FALSE)

and then once in the debugger, run

getOption("device")

This is my output:

function (...)
ragg::agg_png(..., bg = bg)
...

If you have the same, then probably you cannot load the ragg package, so try to (re)install that. If the default device is different, then your issue might be something else, but it'll give you a hint, nevertheless.

Btw. this is probably also mentioned in the standard output, if you look at .Last.error$stdout, as the error message suggests.

jsilve24 commented 1 year ago

@gaborcsardi Just... Wow... I am not sure how you jumped to that conclusions but you were spot on. My output was identical to yours:

Browse[2]> getOption("device")
function (...) 
ragg::agg_png(..., bg = bg)

and install.packages("ragg") fixed all of my issues.

Thank you so much!

tracykteal commented 1 year ago

We truly value respectful, open conversation surrounding open source topics. However, it is also important that the discussions in our organization remain positive and supportive of each other’s efforts. We can disagree, but there’s no need to direct negative comments towards the work of others. Our code of conduct highlights this.

Notably, @stefanoborini, please consider this post a direct warning to not engage in such behavior going forward. I value your work and your thoughts and want your input. But it's counter productive to our organization’s shared goals to be adversarial.

Thank you all for understanding.

stefanoborini commented 1 year ago

@tracykteal Yes, let's all be woke, instead of opening the code and look at what's wrong.

tracykteal commented 1 year ago

Ok, we’ve gone ahead and blocked you across our repositories.