A package that overrides `length()` cannot be rendered

Open
#3,014 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
58/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
r
Domain
documentation

Research direction

Run the reproducer with pkgdown::build_site, then trace the failure from pkgdown:::build_site_local through build_reference, render_page, and data_navbar. Compare the package's exported length() in R/length.R with the reference input man/length.Rd; done means the function reference renders without calling the package's length().

Written by the indexing model from the issue text.

Description

Real-world usage: https://github.com/cynkra/dd . I really wonder what's happening under the hood.

pkg <- file.path(tempdir(), "pkglength")
dir.create(file.path(pkg, "R"), recursive = TRUE, showWarnings = FALSE)

writeLines(c(
  "Package: pkglength",
  "Title: Minimal Package That Exports length()",
  "Version: 0.0.1",
  "Authors@R: person('A', 'B', email = 'a@b.com', role = c('aut', 'cre'))",
  "Description: Reproduces a pkgdown build failure.",
  "License: MIT + file LICENSE",
  "Encoding: UTF-8"
), file.path(pkg, "DESCRIPTION"))

writeLines(c("YEAR: 2026", "COPYRIGHT HOLDER: A B"), file.path(pkg, "LICENSE"))
writeLines("export(length)", file.path(pkg, "NAMESPACE"))
writeLines(c(
  "#' A length() stub",
  "#' @param x Ignored.",
  "#' @return Never returns.",
  "#' @name length",
  "#' @export",
  "length <- function(x) stop('pkglength::length() is not meant to be called')"
), file.path(pkg, "R", "length.R"))

# a man page so as_pkgdown() has a topic to parse
dir.create(file.path(pkg, "man"))
writeLines(c(
  "\\name{length}", "\\alias{length}", "\\title{A length() stub}",
  "\\usage{length(x)}", "\\arguments{\\item{x}{Ignored.}}",
  "\\description{A length() stub.}"
), file.path(pkg, "man", "length.Rd"))

lib <- file.path(tempdir(), "lib")
dir.create(lib, showWarnings = FALSE)
install.packages(pkg, repos = NULL, type = "source", lib = lib)

withr::with_libpaths(lib, action = "prefix", {
  # Real-world entry point (this is what users hit):
  pkgdown::build_site(pkg, new_process = FALSE, install = FALSE)
})
#> ── Initialising site ───────────────────────────────────────────────────────────
#> Copying <pkgdown>/BS3/assets/bootstrap-toc.css to bootstrap-toc.css
#> Copying <pkgdown>/BS3/assets/bootstrap-toc.js to bootstrap-toc.js
#> Copying <pkgdown>/BS3/assets/docsearch.css to docsearch.css
#> Copying <pkgdown>/BS3/assets/docsearch.js to docsearch.js
#> Copying <pkgdown>/BS3/assets/link.svg to link.svg
#> Copying <pkgdown>/BS3/assets/pkgdown.css to pkgdown.css
#> Copying <pkgdown>/BS3/assets/pkgdown.js to pkgdown.js
#> ── Building pkgdown site for package pkglength ─────────────────────────────────
#> 
#> Reading from:
#> /var/folders/dj/yhk9rkx97wn_ykqtnmk18xvc0000gn/T/RtmpIh9aw1/pkglength
#> Writing to:
#> /var/folders/dj/yhk9rkx97wn_ykqtnmk18xvc0000gn/T/RtmpIh9aw1/pkglength/docs
#> ── Sitrep ──────────────────────────────────────────────────────────────────────
#> 
#> ✖ Bootstrap 3 is deprecated; please switch to Bootstrap 5.
#> ℹ Learn more at
#>   <https://www.tidyverse.org/blog/2021/12/pkgdown-2-0-0/#bootstrap-5>.
#> ✖ URLs not ok.
#>   No '_pkgdown.yml' found.
#>   See details in `vignette(pkgdown::metadata)`.
#> ✔ Favicons ok.
#> ✔ Open graph metadata ok.
#> ✔ Articles metadata ok.
#> ✔ Reference metadata ok.
#> ── Initialising site ───────────────────────────────────────────────────────────
#> 
#> ── Building home ───────────────────────────────────────────────────────────────
#> 
#> Writing `authors.html`
#> Writing `LICENSE-text.html`
#> Reading 'DESCRIPTION'
#> Writing `index.html`
#> Writing `404.html`
#> ── Building function reference ─────────────────────────────────────────────────
#> 
#> Writing `reference/index.html`
#> 
#> Attaching package: 'pkglength'
#> 
#> 
#> The following object is masked from 'package:base':
#> 
#>     length
#> 
#> 
#> Reading man/length.Rd
#> Error in `length()`:
#> ! pkglength::length() is not meant to be called

rlang::last_trace()
#> <error/rlang_error>
#> Error in `length()`:
#> ! pkglength::length() is not meant to be called
#> ---
#> Backtrace:
#>      ▆
#>   1. ├─withr::with_libpaths(...)
#>   2. │ └─base::force(code)
#>   3. ├─pkgdown::build_site(pkg, new_process = FALSE, install = FALSE)
#>   4. │ └─pkgdown:::build_site_local(...)
#>   5. │   └─pkgdown::build_reference(...)
#>   6. │     ├─pkgdown:::unwrap_purrr_error(...)
#>   7. │     │ └─base::withCallingHandlers(...)
#>   8. │     └─purrr::map(...)
#>   9. │       └─purrr:::map_("list", .x, .f, ..., .progress = .progress)
#>  10. │         ├─purrr:::with_indexed_errors(...)
#>  11. │         │ └─base::withCallingHandlers(...)
#>  12. │         ├─purrr:::call_with_cleanup(...)
#>  13. │         └─pkgdown (local) .f(.x[[i]], ...)
#>  14. │           └─pkgdown::render_page(...)
#>  15. │             └─pkgdown:::render_page_html(pkg, name = name, data = data, depth = depth)
#>  16. │               ├─pkgdown:::modify_list(data_template(pkg, depth = depth), data)
#>  17. │               └─pkgdown::data_template(pkg, depth = depth)
#>  18. │                 └─pkgdown:::data_navbar(pkg, depth = depth)
#>  19. │                   └─pkgdown:::navbar_links(pkg, depth = depth, call = call)
#>  20. │                     └─pkgdown:::navbar_link_components(pkg, call = call)
#>  21. │                       ├─base::intersect(...)
#>  22. │                       └─pkgdown:::config_pluck_character(...)
#>  23. │                         └─pkgdown:::config_pluck(pkg, path, default)
#>  24. │                           └─purrr::pluck(pkg$meta, !!!where, .default = default)
#>  25. │                             └─purrr:::pluck_raw(.x, list2(...), .default = .default)
#>  26. ├─pkglength::length(`<prnt_yml>`)
#>  27. │ └─base::stop("pkglength::length() is not meant to be called") at pkglength/R/length.R:6:11
#>  28. ├─base::.handleSimpleError(...)
#>  29. │ └─purrr (local) h(simpleError(msg, call))
#>  30. │   └─cli::cli_abort(...)
#>  31. │     └─rlang::abort(...)
#>  32. │       └─rlang:::signal_abort(cnd, .file)
#>  33. │         └─base::signalCondition(cnd)
#>  34. └─pkgdown (local) `<fn>`(`<prrr_rr_>`)
#>  35.   └─rlang::cnd_signal(err$parent)
#>  36.     └─rlang:::signal_abort(cnd)

Created on 2026-07-24 with reprex v2.1.1

Dominant language
R
Stars
775
Forks
355
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from r-lib/pkgdown

All issues in r-lib/pkgdown

Similar issues

More R issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.