| 139 | |
| 140 | == [=#CapturingRlogging Capturing Logging Output From R Package Installation] == |
| 141 | |
| 142 | When you install an R package, the logging output can include multiple screens of information before finally ending with a simple, brief indication of success or failure such as {{{installation of package 'RSQLite' had non-zero exit status}}}. |
| 143 | |
| 144 | As a result, any helpful diagnostic information can be easily lost - including one or more critical error messages that you may not notice as they scroll quickly and entirely out of view and out of your terminal window buffer. |
| 145 | |
| 146 | To avoid this loss of diagnostic information, the R function **install.packages()** provides an option **keep_outputs=T** (or **keep_outputs=TRUE**). |
| 147 | |
| 148 | You can use the **keep_outputs=T** option for capturing the logging output in files - one file per attempted R package - for your later inspection to look for possible error messages - as in the following. |
| 149 | |
| 150 | {{{ |
| 151 | > install.packages("RSQLite", keep_outputs=T) # captures log output in a file RSQLite.out |
| 152 | }}} |
| 153 | |
| 154 | Then from the BASH command line you can search for occurrences of the string {{{error:}}} either via **less** or **grep** BASH commands. (See [https://wiki.hpc.tulane.edu/trac/wiki/cypress/BasicLinuxComands#LinuxCommands Linux Commands].) |
| 155 | |
| 156 | For example in the following, multiple error messages captured in the file **RSQLite.out** indicate that the collection of boost C++ libraries is unexpectedly missing, which can be provided by loading the appropriate module, **boost/1.76.0**, on Cypress. (See [https://wiki.hpc.tulane.edu/trac/wiki/cypress/ModuleCommand#Program:module Module Command].) |
| 157 | |
| 158 | {{{ |
| 159 | [tulaneid@cypress2 ~]$ grep -i error: RSQLite.out |
| 160 | vendor/boost/preprocessor/list/fold_left.hpp(341): catastrophic error: cannot open source file "boost/preprocessor/list/detail/edg/fold_left.hpp" |
| 161 | ... |
| 162 | vendor/boost/preprocessor/list/fold_left.hpp(341): catastrophic error: cannot open source file "boost/preprocessor/list/detail/edg/fold_left.hpp" |
| 163 | ERROR: compilation failed for package ‘RSQLite’ |
| 164 | }}} |
| 165 | |
| 166 | The following excerpt is taken from the output in the R session of {{{> help("install.packages")}}} |
| 167 | |
| 168 | {{{ |
| 169 | keep_outputs: a logical: if true, keep the outputs from installing |
| 170 | source packages in the current working directory, with the |
| 171 | names of the output files the package names with ‘.out’ |
| 172 | appended. Alternatively, a character string giving the |
| 173 | directory in which to save the outputs. Ignored when |
| 174 | installing from local files. |
| 175 | }}} |