yihui / xfun

Miscellaneous R functions
https://yihui.org/xfun/
Other
135 stars 28 forks source link

`session_info()` not work with packages installed via github? #46

Closed chunyunma closed 3 years ago

chunyunma commented 3 years ago

By filing an issue to this repo, I promise that

I understand that my issue may be closed if I don't fulfill my promises.


I really like the concise style of output from session_info(). However, when I included packages installed via github, session_info() would throw an error. For example,

xfun::session_info(c("ggplot2", "ROpenSci/bibtex"), dependencies = FALSE)
# Error in packageVersion(p) : there is no package called 'ROpenSci/bibtex'. 

Is it correct to assume that session_info() only accepts CRAN packages?

Thank you!

yihui commented 3 years ago

The package name shouldn't contain the repo/username, so the code should be

xfun::session_info(c("ggplot2", "bibtex"), dependencies = FALSE)
chunyunma commented 3 years ago

Ah! That's good to know. Thank you!! In hindsight, I could see why I was stuck with the username/repo style. This is what I did in my original script:

cran_packages = c("xx", "xx")
gh_repos = c("xx/xx", "xx/xx")

if (length(cran_packages) != 0) xfun::pkg_load2(cran_packages)
if (length(gh_repos) != 0) xfun::install_github(gh_repos)
xfun::session_info(c(cran_packages, gh_repos), dependencies = F)

I am happy now that I do not need to find an alternative to session_info().