0

I used the pkgdown package to create a new website of my package that will be hosted on Github.
I ran the following codes:

# Run once to configure package to use pkgdown
usethis::use_pkgdown()
# Run to build the website
pkgdown::build_site()

The function pkgdown::build_site has generated a subfolder docs\ in my local repo. You can see in the photo below (red arrow). And I need to push this docs\ subfolder to my Git repo, but I don't know why the docs\ subfolder does not show on my Git commit panel. So now I cannot push my website on GitHub.
enter image description here

Can someone help me spot out what's wrong? And how to fix this?
I have installed the pkgdown package using this command:

install.packages("pkgdown")

However, I was unable to install the development version for GitHub. Is it the reason?? I've tried to install but there're errors showed below:

# Install development version from GitHub
devtools::install_github("hadley/pkgdown")

##  ERROR: package installation failed
## Error: Failed to install 'pkgdown' from GitHub:
##   System command 'Rcmd.exe' failed, exit status: 1, stdout + stderr (last ## 10 lines):
## E> ** inst
## E> ** byte-compile and prepare package for lazy loading
## E> Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) : 
## E>   namespace 'rlang' 0.4.10 is being loaded, but >= 0.99.0.9000 is required
## E> Calls: <Anonymous> ... withCallingHandlers -> loadNamespace -> namespaceImport -> loadNamespace
## E> Execution halted
## E> ERROR: lazy loading failed for package 'pkgdown'
## E> * removing ## 'C:/Users/dokha/AppData/Local/Temp/Rtmpq0XtDc/Rinst212472df268f/pkgdown'
## E>       -----------------------------------
## E> ERROR: package installation failed
## In addition: There were 12 warnings (use warnings() to see them)
torek
  • 448,244
  • 59
  • 642
  • 775
NganKD
  • 71
  • 6
  • Re pkgdown installation, try installing a compatible version of rlang – walter Oct 09 '21 at 20:38
  • Try `devtools::install_github("r-lib/pkgdown")` – ViviG Oct 09 '21 at 21:28
  • @ViviG @walter I've tried both versions of `hadley` & `r-lib`, and I received error messages for both. :( – NganKD Oct 10 '21 at 06:48
  • I just noticed this on your error message: `namespace 'rlang' 0.4.10 is being loaded, but >= 0.99.0.9000 is required` . You really should consider updating your R Studio (or just rlang, but your RStudio is almost certain outdated) – ViviG Oct 10 '21 at 07:01

1 Answers1

1

For reasons I don't totally understand, by default use_pkgdown() adds the docs/ folder to the .gitignore file. That's why it's not showing up in your commit panel. Open up the .gitignore file and delete the reference to docs (should be at the bottom), the docs folder should now appear in your .gitignore and you can commit and push it to your repo.

Perhaps someone from pkgdown can explain why the docs folder is ignored when the instructions say to use it as the GitHub pages source?

> usethis::use_pkgdown()
✓ Setting active project to '/Users/danovan/packages/marlin'
✓ Adding '^_pkgdown\\.yml$', '^docs$' to '.Rbuildignore'
✓ Adding '^pkgdown$' to '.Rbuildignore'
✓ Adding 'docs' to '.gitignore'
DanO
  • 600
  • 3
  • 11
  • Perfect! I've just checked the .gitignore file, removed the `docs` and it works like a charm! Thank you very much. Cheers :) – NganKD Nov 04 '21 at 06:16
  • OK I'm seeing now that the preferred approach if you're publishing via GitHub is to use `usethis::use_pkgdown_github_pages()` rather than pushing the docs folder, but pushing the docs folder works fine as long as its not huge https://pkgdown.r-lib.org/articles/pkgdown.html#publishing – DanO Dec 03 '21 at 18:56