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

Add session_info function #526

Merged
merged 1 commit into from Aug 13, 2014

Conversation

Projects
None yet
2 participants
@wch
Member

wch commented Jul 17, 2014

This overrides the utils:::print.sessionInfo function so that it prints out a package's GithubSHA1 value, if present. Output looks like this:

> library(devtools)
> library(ggvis)
> sessionInfo()
R version 3.1.1 (2014-07-10)
Platform: x86_64-apple-darwin13.1.0 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
[1] ggvis_0.3.0.99(70aef48) devtools_1.5.0.99      

loaded via a namespace (and not attached):
 [1] assertthat_0.1             bitops_1.0-6               caTools_1.17              
 [4] digest_0.6.4               dplyr_0.2                  evaluate_0.5.5            
 [7] htmltools_0.2.4            httpuv_1.3.0               httr_0.3                  
[10] magrittr_1.0.1             memoise_0.2.1              parallel_3.1.1            
[13] Rcpp_0.11.2                RCurl_1.95-4.1             RJSONIO_1.2-0.2           
[16] shiny_0.10.0.9002(89dc132) stringr_0.6.2              tools_3.1.1               
[19] whisker_0.3-2              xtable_1.7-3              

It could also be invoked without loading devtools, with devtools:::print.sessionInfo(sessionInfo()).

@hadley what do you think about this approach, of overriding the print method?

I just realized that one drawback of putting this function in devtools is that simply loading devtools also results in loading a lot of other packages, making it harder to get a clear view of packages loaded when diagnosing some other issue. For example, with a new R session:

> devtools:::print.sessionInfo(sessionInfo())
R version 3.1.1 (2014-07-10)
Platform: x86_64-apple-darwin13.1.0 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

loaded via a namespace (and not attached):
 [1] devtools_1.5.0.99 digest_0.6.4      evaluate_0.5.5    httr_0.3         
 [5] memoise_0.2.1     parallel_3.1.1    RCurl_1.95-4.1    stringr_0.6.2    
 [9] tools_3.1.1       whisker_0.3-2    
@hadley

This comment has been minimized.

Member

hadley commented Jul 17, 2014

I'd rather write our own session_info

@wch wch changed the title from Add print.sessionInfo function to Add session_info function Jul 17, 2014

@wch

This comment has been minimized.

Member

wch commented Jul 17, 2014

OK, I changed it to a function called session_info.

@hadley

This comment has been minimized.

Member

hadley commented Jul 21, 2014

Could we make it more table like? e.g. for the packages, print out a data frame with columns package, version, and loaded. (I don't think we need to separate out base packages)

@hadley

This comment has been minimized.

Member

hadley commented Jul 21, 2014

Maybe something like this:

  loaded_pkg <- grep("^package:", search(), value = TRUE)
  loaded_pkg <- sub("^package:", "", packages)
  attached_pkg <- setdiff(loadedNamespaces(), loaded_pkg)
  loaded <- rep(c(TRUE, FALSE), c(length(loaded_pkg), length(attached_pkg)))

  pkgs <- data.frame(
    package = c(loaded_pkg, attached_pkg),
    loaded = ifelse(loaded, "*", ""),
    stringsAsFactors = FALSE
  )
  pkgs$version <- vapply(pkgs$package, 
    function(x) as.character(packageVersion(x)), 
    character(1)
  )
  pkgs <- pkgs[order(pkgs$package), , drop = FALSE]
  rownames(pkgs) <- NULL

hadley added a commit that referenced this pull request Aug 13, 2014

@hadley hadley merged commit b98d070 into r-lib:master Aug 13, 2014

1 check passed

continuous-integration/travis-ci The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment