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

Capture system console output such as compilation messages #90

Closed
noamross opened this Issue Jun 23, 2017 · 3 comments

Comments

Projects
None yet
2 participants
@noamross

noamross commented Jun 23, 2017

Text printed from the system in the console is not captured by reprex(), For instance, when installing a package, reprex gives this:

devtools::install_github("thomasp85/ggraph", force = TRUE)
#> Using GitHub PAT from envvar GITHUB_PAT
#> Downloading GitHub repo thomasp85/ggraph@master
#> from URL https://api.github.com/repos/thomasp85/ggraph/zipball/master
#> Installing ggraph
#> '/Library/Frameworks/R.framework/Resources/bin/R' --no-site-file  \
#>   --no-environ --no-save --no-restore --quiet CMD INSTALL  \
#>   '/private/var/folders/x5/rj19z1h13zbgffswjx1cc4v00000gn/T/Rtmp5WL6h6/devtools95ec543dce0e/thomasp85-ggraph-9d50611'  \
#>   --library='/Library/Frameworks/R.framework/Versions/3.4/Resources/library'  \
#>   --install-tests
#> 

But running this command in the console without reprex gives this:

> devtools::install_github('thomasp85/ggraph', force=TRUE)
Using GitHub PAT from envvar GITHUB_PAT
Downloading GitHub repo thomasp85/ggraph@master
from URL https://api.github.com/repos/thomasp85/ggraph/zipball/master
Installing ggraph
'/Library/Frameworks/R.framework/Resources/bin/R' --no-site-file --no-environ --no-save --no-restore --quiet CMD INSTALL  \
  '/private/var/folders/x5/rj19z1h13zbgffswjx1cc4v00000gn/T/RtmpMaRw8R/devtools8bfa8c55088/thomasp85-ggraph-9d50611' --library='/Library/Frameworks/R.framework/Versions/3.4/Resources/library'  \
  --install-tests 

* installing *source* package ‘ggraph’ ...
** libs
clang++  -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG  -I"/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcpp/include" -I/usr/local/include   -fPIC  -Wall -g -O2  -c RcppExports.cpp -o RcppExports.o
clang++  -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG  -I"/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcpp/include" -I/usr/local/include   -fPIC  -Wall -g -O2  -c circlePack.cpp -o circlePack.o
clang++  -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG  -I"/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcpp/include" -I/usr/local/include   -fPIC  -Wall -g -O2  -c iciclePlot.cpp -o iciclePlot.o
clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG  -I"/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcpp/include" -I/usr/local/include   -fPIC  -Wall -g -O2  -c init.c -o init.o
clang++  -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG  -I"/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcpp/include" -I/usr/local/include   -fPIC  -Wall -g -O2  -c lineCutter.cpp -o lineCutter.o
clang++  -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG  -I"/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcpp/include" -I/usr/local/include   -fPIC  -Wall -g -O2  -c pathAttr.cpp -o pathAttr.o
clang++  -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG  -I"/Library/Frameworks/R.framework/Versions/3.4/Resources/library/Rcpp/include" -I/usr/local/include   -fPIC  -Wall -g -O2  -c treemap.cpp -o treemap.o
clang++ -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o ggraph.so RcppExports.o circlePack.o iciclePlot.o init.o lineCutter.o pathAttr.o treemap.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
installing to /Library/Frameworks/R.framework/Versions/3.4/Resources/library/ggraph/libs
** R
** data
*** moving datasets to lazyload DB
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (ggraph)

I'm not actually sure what is what here - the clang compile statments print in black in the RStudio console, while the lines starting with * characters is in red in the console, and also skipped by reprex(). Capturing the compile statements is useful for reporting installation/compile problems. Perhaps this can be done using sink() or capture.output()?

jennybc added a commit that referenced this issue Sep 24, 2017

@jennybc

This comment has been minimized.

Member

jennybc commented Sep 24, 2017

@noamross If you're willing to try this out, that would be great. What do you think? Should it be in a collapsible section, like session info, I wonder?

devtools::install_github("tidyverse/reprex@capture-system-output")

Example with a simple and straightforward system() call:

reprex call:

reprex(system("whoami"), std_out_err = TRUE)

output:

system("whoami")

standard output and standard error

#> jenny

Example that installs a source package from GitHub:

reprex call:

reprex(
  devtools::install_github('tidyverse/purrr', force = TRUE),
  std_out_err = TRUE
)

output:

devtools::install_github("tidyverse/purrr", force = TRUE)
#> Using GitHub PAT from envvar GITHUB_PAT
#> Downloading GitHub repo tidyverse/purrr@master
#> from URL https://api.github.com/repos/tidyverse/purrr/zipball/master
#> Installing purrr
#> '/Library/Frameworks/R.framework/Resources/bin/R' --no-site-file  \
#>   --no-environ --no-save --no-restore --quiet CMD INSTALL  \
#>   '/private/var/folders/vr/gzrbtprx6ybg85y5pvwm1ct40000gn/T/RtmpwjAsWm/devtools933050dd057c/tidyverse-purrr-097891a'  \
#>   --library='/Users/jenny/resources/R/library' --install-tests
#> 

standard output and standard error

#> * installing *source* package ‘purrr’ ...
#> ** libs
#> clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/include   -fPIC  -g -O2 -Wall -pedantic -mtune=native -c coerce.c -o coerce.o
#> clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/include   -fPIC  -g -O2 -Wall -pedantic -mtune=native -c extract.c -o extract.o
#> clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/include   -fPIC  -g -O2 -Wall -pedantic -mtune=native -c flatten.c -o flatten.o
#> clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/include   -fPIC  -g -O2 -Wall -pedantic -mtune=native -c init.c -o init.o
#> clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/include   -fPIC  -g -O2 -Wall -pedantic -mtune=native -c map.c -o map.o
#> clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG   -I/usr/local/include   -fPIC  -g -O2 -Wall -pedantic -mtune=native -c transpose.c -o transpose.o
#> clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o purrr.so coerce.o extract.o flatten.o init.o map.o transpose.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
#> installing to /Users/jenny/resources/R/library/purrr/libs
#> ** R
#> ** tests
#> ** preparing package for lazy loading
#> ** help
#> *** installing help indices
#> *** copying figures
#> ** building package indices
#> ** installing vignettes
#> ** testing if installed package can be loaded
#> * DONE (purrr)

jennybc added a commit that referenced this issue Sep 24, 2017

jennybc added a commit that referenced this issue Sep 24, 2017

@jennybc

This comment has been minimized.

Member

jennybc commented Sep 24, 2017

BTW it still needs refinement, such as not including that section if there is no such output.

jennybc added a commit that referenced this issue Sep 26, 2017

@jennybc

This comment has been minimized.

Member

jennybc commented Sep 27, 2017

About to merge this but am not wed to every last detail. It's working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment