Skip to content
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

Empty README.md file in package root directory causes error #2309

Closed
jonnybaik opened this issue May 19, 2023 · 1 comment · Fixed by #2466
Closed

Empty README.md file in package root directory causes error #2309

jonnybaik opened this issue May 19, 2023 · 1 comment · Fixed by #2466
Labels
bug an unexpected problem or unintended behavior home 🏠

Comments

@jonnybaik
Copy link

jonnybaik commented May 19, 2023

I initialized a package with an empty README.md intending to fill it in later, and when I later tried to build a site with pkgdown::build_site(), I ran into an error:

> # Build pkgdown documentation site
> build_site(pkg = "/path/to/R/package")

-- Installing package into temporary library -----------------------------------Using R 4.2.3 (lockfile was generated with R 4.1.3)
== Building pkgdown site =======================================================
Reading from: '/path/to/R/package'
Writing to:   '/path/to/R/package/docs'
-- Initialising site -----------------------------------------------------------
-- Building home ---------------------------------------------------------------
Error: 
! in callr subprocess.
Caused by error in `UseMethod("xml_find_first")`:
! no applicable method for 'xml_find_first' applied to an object of class "NULL"See `$stdout` for standard output.
Type .Last.error to see the more details.


> .Last.error

<callr_error/rlib_error_3_0/rlib_error/error>
Error: 
! in callr subprocess.
Caused by error in `UseMethod("xml_find_first")`:
! no applicable method for 'xml_find_first' applied to an object of class "NULL"See `$stdout` for standard output.
---
Backtrace:
1. pkgdown::build_site(pkg = "/path/to/R/package")
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_home(pkg, override = override, preview = FALSE)
 4. pkgdown::build_home_index(pkg, quiet = quiet)
 5. pkgdown:::markdown_body(src_path)
 6. xml %>% xml2::xml_find_first(".//body") %>% xml2::write_html(transformed_path, …
 7. xml2::write_html(., transformed_path, format = FALSE)
 8. xml2::xml_find_first(., ".//body")
 9. base::.handleSimpleError(function (e) …
10. global h(simpleError(msg, call))

The error wasn't very informative, but I was able to fix the issue by removing the README.md file in the package root directory.

Following the error trace, the build_home_index() function seems to check if specific files exist (e.g. "pkgdown/index.md", "index.md", "README.md"), but if those files exist and are empty, it results in an error.

@maelle
Copy link
Collaborator

maelle commented May 25, 2023

Oh, interesting edge case, maybe pkgdown should indeed first check the file is not empty. 🤔

Another way to create a README.md to fill in later would be to run usethis::use_readme_md(), with which you get a boilerplate README.

@hadley hadley added bug an unexpected problem or unintended behavior home 🏠 labels Oct 30, 2023
hadley added a commit that referenced this issue Apr 18, 2024
hadley added a commit that referenced this issue Apr 18, 2024
SebKrantz pushed a commit to SebKrantz/pkgdown that referenced this issue Jun 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior home 🏠
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants