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

Bug: Error in loadNamespace(name) : there is no package called ‘pkg’ when running pkgdown::build_site() #2155

Closed
talgalili opened this issue Jul 3, 2022 · 10 comments

Comments

@talgalili
Copy link

Reproduce (while working on the dendextend package):

>  pkgdown::build_site()
-- Installing package into temporary library -------------------------------------------------
== Building pkgdown site =======================================================
Reading from: '/home/talgalili/Dropbox/aaaa good R code/AA - My packages/dendextend'
Writing to:   '/home/talgalili/Dropbox/aaaa good R code/AA - My packages/dendextend/docs'
-- Initialising site -----------------------------------------------------------
-- Building home ---------------------------------------------------------------
Writing 'authors.html'
Reading 'CONDUCT.md'
Writing 'CONDUCT.html'
Error in loadNamespace(name) : there is no package called ‘pkg’
Error: callr subprocess failed: there is no package called ‘pkg’
Type .Last.error.trace to see where the error occurred

`sessionInfo()` log (notice that this is an old R: 3.6.3, on linux MINT 19.2)
 
--
> sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Linux Mint 19.2

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1

Random number generation:
 RNG:     Mersenne-Twister 
 Normal:  Inversion 
 Sample:  Rounding 
 
locale:
 [1] LC_CTYPE=en_IL.UTF-8       LC_NUMERIC=C               LC_TIME=en_IL.UTF-8       
 [4] LC_COLLATE=en_IL.UTF-8     LC_MONETARY=en_IL.UTF-8    LC_MESSAGES=en_IL.UTF-8   
 [7] LC_PAPER=en_IL.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=en_IL.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] pkgdown_2.0.5     dendextend_1.16.0

loaded via a namespace (and not attached):
 [1] tidyselect_1.1.2  xfun_0.21         remotes_2.2.0     purrr_0.3.4       colorspace_2.0-0 
 [6] vctrs_0.4.1       generics_0.1.0    htmltools_0.5.2   viridisLite_0.3.0 yaml_2.2.1       
[11] utf8_1.1.4        rlang_1.0.3       pillar_1.7.0      glue_1.6.2        withr_2.5.0      
[16] DBI_1.1.1         lifecycle_1.0.1   munsell_0.5.0     gtable_0.3.0      memoise_2.0.0    
[21] evaluate_0.14     knitr_1.31        callr_3.7.0       fastmap_1.1.0     ps_1.5.0         
[26] curl_4.3          fansi_0.4.2       scales_1.1.1      cachem_1.0.4      desc_1.2.0       
[31] jsonlite_1.7.2    fs_1.5.0          gridExtra_2.3     ggplot2_3.3.3     digest_0.6.27    
[36] processx_3.6.1    dplyr_1.0.9       grid_3.6.3        rprojroot_2.0.2   cli_3.3.0        
[41] tools_3.6.3       magrittr_2.0.1    tibble_3.1.7      crayon_1.4.1      whisker_0.4      
[46] pkgconfig_2.0.3   downlit_0.4.1     ellipsis_0.3.2    xml2_1.3.2        assertthat_0.2.1 
[51] rmarkdown_2.7     httr_1.4.2        rstudioapi_0.13   viridis_0.5.1     R6_2.5.0         
[56] compiler_3.6.3   
@dmurdoch
Copy link
Contributor

dmurdoch commented Jul 3, 2022

What does .Last.error.trace show you?

@dmurdoch
Copy link
Contributor

dmurdoch commented Jul 3, 2022

In your README.md, you have this:

install.packages.2 <- function (pkg) if (!require(pkg)) install.packages(pkg);

I think that should have been

install.packages.2 <- function (pkg) if (!requireNamespace(pkg)) install.packages(pkg);

because normally you don't want to add things to the search list. But if you really want to use require(), you need the character.only = TRUE argument so that it doesn't try to load the package named "pkg".

@talgalili
Copy link
Author

Interesting, let me take a look :)

@talgalili
Copy link
Author

Output

> .Last.error.trace

 Stack trace:

 Process 17264:
 1. pkgdown::build_site()
 2. pkgdown:::build_site_external(pkg = pkg, examples = examples,  ...
 3. callr::r(function(..., crayon_enabled, crayon_colors, pkgdown_internet) { ...
 4. callr:::get_result(output = out, options)
 5. throw(newerr, parent = remerr[[2]])

 x callr subprocess failed: there is no package called ‘pkg’ 

 Process 17386:
 17. (function (..., crayon_enabled, crayon_colors, pkgdown_internet)  ...
 18. pkgdown::build_site(...)
 19. pkgdown:::build_site_local(pkg = pkg, examples = examples, run_dont_run = r ...
 20. pkgdown:::build_home(pkg, override = override, preview = FALSE)
 21. pkgdown:::build_home_index(pkg, quiet = quiet)
 22. pkgdown:::render_page(pkg, "home", data, "index.html", quiet = quiet)
 23. pkgdown:::tweak_page(html, name, pkg = pkg)
 24. downlit::downlit_html_node(html)
 25. downlit:::tweak_children(x, xpath_block, highlight, pre_class = "downlit so ...
 26. downlit:::map_chr(text, fun, ...)
 27. base:::vapply(.x, .f, ..., FUN.VALUE = character(1), USE.NAMES = FALSE)
 28. downlit:::FUN(X[[i]], ...)
 29. downlit:::token_href(out$token, out$text)
 30. downlit:::map_chr(text[fun], href_topic_local, is_fun = TRUE)
 31. base:::vapply(.x, .f, ..., FUN.VALUE = character(1), USE.NAMES = FALSE)
 32. downlit:::FUN(X[[i]], ...)
 33. downlit:::find_rdname_attached(topic, is_fun = is_fun)
 34. downlit:::is_exported(topic, package)
 35. base:::`%in%`(name, getNamespaceExports(ns_env(package)))
 36. base:::getNamespaceExports(ns_env(package))
 37. base:::asNamespace(ns)
 38. rlang:::ns_env(package)
 39. base:::asNamespace(x)
 40. base:::getNamespace(ns)
 41. base:::loadNamespace(name)
 42. base:::withRestarts(stop(cond), retry_loadNamespace = function() NULL)
 43. base:::withOneRestart(expr, restarts[[1L]])
 44. base:::doWithOneRestart(return(expr), restart)
 45. base:::stop(cond)
 46. (function (e)  ...

 x there is no package called ‘pkg’ 

@dmurdoch
Copy link
Contributor

dmurdoch commented Jul 3, 2022

That error is coming from downlit, which wants to make a link to some topic, probably on the pkg website.

@talgalili
Copy link
Author

Changing to use:
install.packages.2 <- function (pkg) if (!require(pkg, character.only = TRUE))
Seems to have solved it.

It still crashes (but because I'm missing a package). Is there a way to force skip it when this happens, instead of letting it crash?

>  pkgdown::build_site()
-- Installing package into temporary library -------------------------------------------------
== Building pkgdown site =======================================================
Reading from: '/home/talgalili/Dropbox/aaaa good R code/AA - My packages/dendextend'
Writing to:   '/home/talgalili/Dropbox/aaaa good R code/AA - My packages/dendextend/docs'
-- Initialising site -----------------------------------------------------------
-- Building home ---------------------------------------------------------------
Reading 'CONDUCT.md'
Writing '404.html'
-- Building function reference -------------------------------------------------
|
---------------------
Welcome to dendextend version 1.16.0
Type citation('dendextend') for how to cite the package.

Type browseVignettes(package = 'dendextend') for the package vignette.
The github page is: https://github.com/talgalili/dendextend/

Suggestions and bug-reports can be submitted at: https://github.com/talgalili/dendextend/issues
You may ask questions at stackoverflow, use the r and dendextend tags: 
	 https://stackoverflow.com/questions/tagged/dendextend

	To suppress this message use:  suppressPackageStartupMessages(library(dendextend))
---------------------

/
Attaching package: ‘dendextend’

The following object is masked from ‘package:stats’:

    cutree

Reading 'man/Bk.Rd'
Reading 'man/Bk_permutations.Rd'
Reading 'man/Bk_plot.Rd'
Reading 'man/DendSer.dendrogram.Rd'
Registered S3 method overwritten by 'seriation':
  method         from 
  reorder.hclust gclus
Reading 'man/FM_index.Rd'
Reading 'man/FM_index_R.Rd'
Reading 'man/FM_index_permutation.Rd'
Error in .f(.x[[i]], ...) : Failed to parse Rd in FM_index_permutation.Rd
ℹ there is no package called ‘psych’
Caused by error in `loadNamespace()`:
! there is no package called ‘psych’
Error: callr subprocess failed: Failed to parse Rd in FM_index_permutation.Rd
ℹ there is no package called ‘psych’
Caused by error in `loadNamespace()`:
! there is no package called ‘psych’
Type .Last.error.trace to see where the error occurred

(I can't seem to install psych, but that's another issue, unrelated to pkgdown)

@talgalili
Copy link
Author

And thanks a lot @dmurdoch for the super fast and helpful responses!

@dmurdoch
Copy link
Contributor

dmurdoch commented Jul 3, 2022

I think the psych issue might be fixed in the devel version of downlit, by this commit: r-lib/downlit@24ccb0b .

@talgalili
Copy link
Author

I take it back, I think the bug still occurs even after moving to use the following in README.md:

install.packages.2 <- function (pkg) {
   if (!require(pkg, character.only = TRUE)) 
   install.packages(pkg, character.only = TRUE)
   }

Output

> pkgdown::build_home()
-- Building home ------------------------------------------------------------------------------
Reading 'CONDUCT.md'
Error in loadNamespace(name) : there is no package called ‘pkg’

@talgalili talgalili reopened this Jul 3, 2022
talgalili added a commit to talgalili/dendextend that referenced this issue Jul 3, 2022
gaborcsardi added a commit to r-lib/asciicast that referenced this issue Jul 3, 2022
@dmurdoch
Copy link
Contributor

dmurdoch commented Jul 3, 2022

I think there are issues in downlit still. In particular, autolink_url() calls href_expr, and it doesn't handle library, require and requireNamespace properly. I suspect that's where the problem arises. I'll open an issue there...

@hadley hadley closed this as completed Jul 5, 2022
clrpackages pushed a commit to clearlinux-pkgs/R-dendextend that referenced this issue Jul 7, 2022
…sion 1.16.0

dendextend 1.16.0 (2022-07-04)
----------------------------------------
###UPDATED FUNCTIONS:
* set - added two new arguments: leaves_bg and nodes_bg (which provide a fill color when pch is between 21-25). Props to Patrick Schupp <pschupp@sonic.net> (https://github.com/pschupp)

###BUG FIXES
- Fix minor error in the docs of color_branches
- Fix
  checking Rd cross-references ... NOTE
  Undeclared packages ‘WGCNA’, ‘moduleColor’, ‘distory’, ‘phangorn’, ‘zoo’ in Rd xrefs
- Remove (undocumented!) dependancy on the psych library.
- Fix an issue with running `pkgdown::build_site()` (see: r-lib/pkgdown#2155). Props to @dmurdoch.

###OTHER NOTES
- as.phylo - Remove example dependancy on ggdendro

(NEWS truncated at 15 lines)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants