callr/ 0000755 0001762 0000144 00000000000 14564733763 011371 5 ustar ligges users callr/NAMESPACE 0000644 0001762 0000144 00000001243 14520207124 012563 0 ustar ligges users # Generated by roxygen2: do not edit by hand
S3method(format,callr_status_error)
S3method(print,callr_status_error)
export(add_hook)
export(default_repos)
export(poll)
export(process)
export(r)
export(r_bg)
export(r_copycat)
export(r_process)
export(r_process_options)
export(r_safe)
export(r_session)
export(r_session_options)
export(r_vanilla)
export(rcmd)
export(rcmd_bg)
export(rcmd_copycat)
export(rcmd_process)
export(rcmd_process_options)
export(rcmd_safe)
export(rcmd_safe_env)
export(rscript)
export(rscript_process)
export(rscript_process_options)
export(run)
export(supported_archs)
importFrom(processx,poll)
importFrom(processx,process)
importFrom(processx,run)
callr/LICENSE 0000644 0001762 0000144 00000000061 14564626131 012361 0 ustar ligges users YEAR: 2024
COPYRIGHT HOLDER: see COPYRIGHTS file
callr/README.md 0000644 0001762 0000144 00000025334 14521175632 012643 0 ustar ligges users
# callr
> Call R from R
[](https://lifecycle.r-lib.org/articles/stages.html)
[](https://github.com/r-lib/callr/actions/workflows/R-CMD-check.yaml)
[](https://www.r-pkg.org/pkg/callr)
[](https://www.r-pkg.org/pkg/callr)
[](https://app.codecov.io/gh/r-lib/callr?branch=main)
It is sometimes useful to perform a computation in a separate R process,
without affecting the current R process at all. This packages does exactly
that.
---
- [Features](#features)
- [Installation](#installation)
- [Synchronous, one-off R processes](#synchronous-one-off-r-processes)
- [Passing arguments](#passing-arguments)
- [Using packages](#using-packages)
- [Error handling](#error-handling)
- [Standard output and error](#standard-output-and-error)
- [Background R processes](#background-r-processes)
- [Multiple background R processes and
`poll()`](#multiple-background-r-processes-and-poll)
- [Persistent R sessions](#persistent-r-sessions)
- [Running `R CMD` commands](#running-r-cmd-commands)
- [Code of Conduct](#code-of-conduct)
## Features
- Calls an R function, with arguments, in a subprocess.
- Copies function arguments to the subprocess and copies the return
value of the function back, seamlessly.
- Copies error objects back from the subprocess, including a stack
trace.
- Shows and/or collects the standard output and standard error of the
subprocess.
- Supports both one-off and persistent R subprocesses.
- Calls the function synchronously or asynchronously (in the
background).
- Can call `R CMD` commands, synchronously or asynchronously.
- Can call R scripts, synchronously or asynchronously.
- Provides extensible `r_process`, `rcmd_process` and `rscript_process`
R6 classes, based on `processx::process`.
## Installation
Install the stable version from CRAN:
``` r
install.packages("callr")
```
Install the development version from GitHub:
``` r
pak::pak("r-lib/callr")
```
## Synchronous, one-off R processes
Use `r()` to run an R function in a new R process. The results are
passed back seamlessly:
``` r
callr::r(function() var(iris[, 1:4]))
```
### Passing arguments
You can pass arguments to the function by setting `args` to the list of
arguments. This is often necessary as these arguments are explicitly
copied to the child process, whereas the evaluated function cannot refer
to variables in the parent. For example, the following does not work:
``` r
mycars <- cars
callr::r(function() summary(mycars))
```
But this does:
``` r
mycars <- cars
callr::r(function(x) summary(x), args = list(mycars))
```
Note that the arguments will be serialized and saved to a file, so if
they are large R objects, it might take a long time for the child
process to start up.
### Using packages
You can use any R package in the child process, just make sure to refer
to it explicitly with the `::` operator. For example, the following code
creates an [igraph](https://github.com/igraph/rigraph) graph in the
child, and calculates some metrics of it.
``` r
callr::r(function() { g <- igraph::sample_gnp(1000, 4/1000); igraph::diameter(g) })
```
### Error handling
callr copies errors from the child process back to the main R session:
``` r
callr::r(function() 1 + "A")
```
callr sets the
`.Last.error` variable, and after an error you can inspect this for more
details about the error, including stack traces both from the main R
process and the subprocess.
``` r
.Last.error
```
The error objects has two parts. The first belongs to the main process,
and the second belongs to the subprocess.
`.Last.error` also includes a stack trace, that includes both the main R
process and the subprocess:
The top part of the trace contains the frames in the main process, and
the bottom part contains the frames in the subprocess, starting with the
anonymous function.
### Standard output and error
By default, the standard output and error of the child is lost, but you
can request callr to redirect them to files, and then inspect the files
in the parent:
``` r
x <- callr::r(function() { print("hello world!"); message("hello again!") },
stdout = "/tmp/out", stderr = "/tmp/err"
)
readLines("/tmp/out")
```
``` r
readLines("/tmp/err")
```
With the `stdout` option, the standard output is collected and can be
examined once the child process finished. The `show = TRUE` options will
also show the output of the child, as it is printed, on the console of
the parent.
## Background R processes
`r_bg()` is similar to `r()` but it starts the R process in the
background. It returns an `r_process` R6 object, that provides a rich
API:
``` r
rp <- callr::r_bg(function() Sys.sleep(.2))
rp
```
This is a list of all `r_process` methods:
``` r
ls(rp)
```
These include all methods of the `processx::process` superclass and the
new `get_result()` method, to retrieve the R object returned by the
function call. Some of the handiest methods are:
- `get_exit_status()` to query the exit status of a finished process.
- `get_result()` to collect the return value of the R function call.
- `interrupt()` to send an interrupt to the process. This is equivalent
to a `CTRL+C` key press, and the R process might ignore it.
- `is_alive()` to check if the process is alive.
- `kill()` to terminate the process.
- `poll_io()` to wait for any standard output, standard error, or the
completion of the process, with a timeout.
- `read_*()` to read the standard output or error.
- `suspend()` and `resume()` to stop and continue a process.
- `wait()` to wait for the completion of the process, with a timeout.
## Multiple background R processes and `poll()`
Multiple background R processes are best managed with the
`processx::poll()` function that waits for events (standard output/error
or termination) from multiple processes. It returns as soon as one
process has generated an event, or if its timeout has expired. The
timeout is in milliseconds.
``` r
rp1 <- callr::r_bg(function() { Sys.sleep(1/2); "1 done" })
rp2 <- callr::r_bg(function() { Sys.sleep(1/1000); "2 done" })
processx::poll(list(rp1, rp2), 1000)
```
``` r
rp2$get_result()
```
``` r
processx::poll(list(rp1), 1000)
```
``` r
rp1$get_result()
```
## Persistent R sessions
`r_session` is another `processx::process` subclass that represents a
persistent background R session:
``` r
rs <- callr::r_session$new()
rs
```
`r_session$run()` is a synchronous call, that works similarly to `r()`,
but uses the persistent session. `r_session$call()` starts the function
call and returns immediately. The `r_session$poll_process()` method or
`processx::poll()` can then be used to wait for the completion or other
events from one or more R sessions, R processes or other
`processx::process` objects.
Once an R session is done with an asynchronous computation, its
`poll_process()` method returns `"ready"` and the `r_session$read()`
method can read out the result.
``` r
rs <- callr::r_session$new()
rs$run(function() runif(10))
```
``` r
rs$call(function() rnorm(10))
rs
```
``` r
rs$poll_process(2000)
```
``` r
rs$read()
```
## Running `R CMD` commands
The `rcmd()` function calls an `R CMD` command. For example, you can
call `R CMD INSTALL`, `R CMD check` or `R CMD config` this way:
``` r
callr::rcmd("config", "CC")
```
This returns a list with three components: the standard output, the
standard error, and the exit (status) code of the `R CMD` command.
## Code of Conduct
Please note that the callr project is released with a [Contributor Code
of Conduct](https://callr.r-lib.org/CODE_OF_CONDUCT.html). By
contributing to this project, you agree to abide by its terms.
callr/man/ 0000755 0001762 0000144 00000000000 14564626344 012140 5 ustar ligges users callr/man/r_vanilla.Rd 0000644 0001762 0000144 00000006516 14326533425 014377 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/presets.R
\name{r_vanilla}
\alias{r_vanilla}
\title{Run an R child process, with no configuration}
\usage{
r_vanilla(
func,
args = list(),
libpath = character(),
repos = c(CRAN = "@CRAN@"),
cmdargs = "--slave",
system_profile = FALSE,
user_profile = FALSE,
env = character(),
...
)
}
\arguments{
\item{func}{Function object to call in the new R process.
The function should be self-contained and only refer to
other functions and use variables explicitly from other packages
using the \code{::} notation. By default the environment of the function
is set to \code{.GlobalEnv} before passing it to the child process.
(See the \code{package} option if you want to keep the environment.)
Because of this, it is good practice to create an anonymous
function and pass that to \code{callr}, instead of passing
a function object from a (base or other) package. In particular
\if{html}{\out{
}}\preformatted{r(.libPaths)
}\if{html}{\out{
}}
does not work, because \code{.libPaths} is defined in a special
environment, but
\if{html}{\out{
}}
works just fine.}
\item{args}{Arguments to pass to the function. Must be a list.}
\item{libpath}{The library path.}
\item{repos}{The \code{repos} option. If \code{NULL}, then no
\code{repos} option is set. This options is only used if
\code{user_profile} or \code{system_profile} is set \code{FALSE},
as it is set using the system or the user profile.}
\item{cmdargs}{Command line arguments to pass to the R process.
Note that \code{c("-f", rscript)} is appended to this, \code{rscript}
is the name of the script file to run. This contains a call to the
supplied function and some error handling code.}
\item{system_profile}{Whether to use the system profile file.}
\item{user_profile}{Whether to use the user's profile file.
If this is \code{"project"}, then only the profile from the working
directory is used, but the \code{R_PROFILE_USER} environment variable
and the user level profile are not. See also "Security considerations"
below.}
\item{env}{Environment variables to set for the child process.}
\item{...}{Additional arguments are passed to \code{\link[=r]{r()}}.}
}
\description{
It tries to mimic a fresh R installation. In particular:
\itemize{
\item No library path setting.
\item No CRAN(-like) repository is set.
\item The system and user profiles are not run.
}
}
\section{Security considerations}{
\code{callr} makes a copy of the user's \code{.Renviron} file and potentially of
the local or user \code{.Rprofile}, in the session temporary
directory. Avoid storing sensitive information such as passwords, in
your environment file or your profile, otherwise this information will
get scattered in various files, at least temporarily, until the
subprocess finishes. You can use the keyring package to avoid passwords
in plain files.
}
\examples{
\dontshow{if (FALSE) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf}
# Compare to r()
r(function() .libPaths())
r_vanilla(function() .libPaths())
r(function() getOption("repos"))
r_vanilla(function() getOption("repos"))
\dontshow{\}) # examplesIf}
}
\seealso{
Other callr functions:
\code{\link{r_copycat}()},
\code{\link{r}()}
}
\concept{callr functions}
callr/man/r_session_debug.Rd 0000644 0001762 0000144 00000004760 14326534733 015604 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/r-session.R
\name{r_session_debug}
\alias{r_session_debug}
\title{Interactive debugging of persistent R sessions}
\description{
The \code{r_session$debug()} method is an interactive debugger to inspect
the stack of the background process after an error.
}
\details{
Note that on callr version 3.8.0 and above, you need to set the
\code{callr.traceback} option to \code{TRUE} (in the main process) to make
the subprocess dump the frames on error. This is because saving
the frames can be costly for large objects passed as arguments.
\verb{$debug()} starts a REPL (Read-Eval-Print-Loop), that evaluates R
expressions in the subprocess. It is similar to \code{\link[=browser]{browser()}} and
\code{\link[=debugger]{debugger()}} and also has some extra commands:
\itemize{
\item \code{.help} prints a short help message.
\item \code{.where} prints the complete stack trace of the error. (The same as
the \verb{$traceback()} method.
\item \verb{.inspect } switches the "focus" to frame \verb{}. Frame 0 is the
global environment, so \verb{.inspect 0} will switch back to that.
}
To exit the debugger, press the usual interrupt key, i.e. \code{CTRL+c} or
\code{ESC} in some GUIs.
Here is an example session that uses \verb{$debug()} (some output is omitted
for brevity):
\if{html}{\out{
}}
\describe{
\item{\code{options}}{A list of options created via
\code{\link[=rcmd_process_options]{rcmd_process_options()}}.}
}
\if{html}{\out{
}}
}
\subsection{Returns}{
A new \code{rcmd_process} object.
}
}
\if{html}{\out{}}
\if{html}{\out{}}
\if{latex}{\out{\hypertarget{method-rcmd_process-finalize}{}}}
\subsection{Method \code{finalize()}}{
Clean up the temporary files created for an \verb{R CMD} process.
\subsection{Usage}{
\if{html}{\out{
}}
}
}
\if{html}{\out{}}
\if{html}{\out{}}
\if{latex}{\out{\hypertarget{method-rcmd_process-clone}{}}}
\subsection{Method \code{clone()}}{
The objects of this class are cloneable with this method.
\subsection{Usage}{
\if{html}{\out{
}}
\describe{
\item{\code{deep}}{Whether to make a deep clone.}
}
\if{html}{\out{
}}
}
}
}
callr/man/r_session_options.Rd 0000644 0001762 0000144 00000004016 14326534733 016203 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/r-session.R
\name{r_session_options}
\alias{r_session_options}
\title{Create options for an \link{r_session} object}
\usage{
r_session_options(...)
}
\arguments{
\item{...}{Options to override, named arguments.}
}
\value{
Named list of options.
The current options are:
\itemize{
\item \code{libpath}: Library path for the subprocess. By default the same as the
\emph{current} library path. I.e. \emph{not} necessarily the library path of
a fresh R session.)
\item \code{repos}: \code{repos} option for the subprocess. By default the current
value of the main process.
\item \code{stdout}: Standard output of the sub-process. This can be \code{NULL} or
a pipe: \code{"|"}. If it is a pipe then the output of the subprocess is
not included in the responses, but you need to poll and read it
manually. This is for experts. Note that this option is not used
for the startup phase that currently always runs with \code{stdout = "|"}.
\item \code{stderr}: Similar to \code{stdout}, but for the standard error. Like
\code{stdout}, it is not used for the startup phase, which runs with
\code{stderr = "|"}.
\item \code{error}: See 'Error handling' in \code{\link[=r]{r()}}.
\item \code{cmdargs}: See the same argument of \code{\link[=r]{r()}}. (Its default might be
different, though.)
\item \code{system_profile}: See the same argument of \code{\link[=r]{r()}}.
\item \code{user_profile}: See the same argument of \code{\link[=r]{r()}}.
\item \code{env}: See the same argument of \code{\link[=r]{r()}}.
\item \code{load_hook}: \code{NULL}, or code (quoted) to run in the sub-process
at start up. (I.e. not for every single \code{run()} call.)
\item \code{extra}: List of extra arguments to pass to \link[processx:process]{processx::process}.
}
Call \code{r_session_options()} to see the default values.
\code{r_session_options()} might contain undocumented entries, you cannot
change these.
}
\description{
Create options for an \link{r_session} object
}
\examples{
r_session_options()
}
callr/man/callr-package.Rd 0000644 0001762 0000144 00000061270 14564553726 015126 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/callr-package.R
\docType{package}
\name{callr-package}
\alias{callr}
\alias{callr-package}
\title{Call R from R}
\description{
It is sometimes useful to perform a computation in a separate
R process, without affecting the current R process at all. This
packages does exactly that.
}
\section{callr}{
\subsection{Features}{
\itemize{
\item Calls an R function, with arguments, in a subprocess.
\item Copies function arguments to the subprocess and copies the return value of the function back, seamlessly.
\item Copies error objects back from the subprocess, including a stack trace.
\item Shows and/or collects the standard output and standard error of the subprocess.
\item Supports both one-off and persistent R subprocesses.
\item Calls the function synchronously or asynchronously (in the background).
\item Can call \verb{R CMD} commands, synchronously or asynchronously.
\item Can call R scripts, synchronously or asynchronously.
\item Provides extensible \code{r_process}, \code{rcmd_process} and \code{rscript_process} R6 classes, based on \code{processx::process}.
}
}
\subsection{Installation}{
Install the stable version from CRAN:
\if{html}{\out{
}}
}
\subsection{Synchronous, one-off R processes}{
Use \code{r()} to run an R function in a new R process.
The results are passed back seamlessly:
\if{html}{\out{
}}
\subsection{Passing arguments}{
You can pass arguments to the function by setting \code{args} to the list of arguments.
This is often necessary as these arguments are explicitly copied to the child process, whereas the evaluated function cannot refer to variables in the parent.
For example, the following does not work:
\if{html}{\out{
#> Error:
#> ! in callr subprocess.
#> Caused by error in `summary(mycars)`:
#> ! object 'mycars' not found
#> Type .Last.error to see the more details.
#> speed dist
#> Min. : 4.0 Min. : 2.00
#> 1st Qu.:12.0 1st Qu.: 26.00
#> Median :15.0 Median : 36.00
#> Mean :15.4 Mean : 42.98
#> 3rd Qu.:19.0 3rd Qu.: 56.00
#> Max. :25.0 Max. :120.00
}}
Note that the arguments will be serialized and saved to a file, so if they are large R objects, it might take a long time for the child process to start up.
}
\subsection{Using packages}{
You can use any R package in the child process, just make sure to refer to it explicitly with the \code{::} operator.
For example, the following code creates an \href{https://github.com/igraph/rigraph}{igraph} graph in the child, and calculates some metrics of it.
\if{html}{\out{
}}\preformatted{callr::r(function() \{ g <- igraph::sample_gnp(1000, 4/1000); igraph::diameter(g) \})
}\if{html}{\out{
}}\if{html}{\out{
#> [1] 11
}}
}
\subsection{Error handling}{
callr copies errors from the child process back to the main R session:
\if{html}{\out{
#> Error:
#> ! in callr subprocess.
#> Caused by error in `1 + "A"`:
#> ! non-numeric argument to binary operator
#> Type .Last.error to see the more details.
callr sets the `.Last.error` variable, and after an error you can inspect this for more details about the error, including stack traces both from the main R process and the subprocess.
}}
\if{html}{\out{
}}
The error objects has two parts.
The first belongs to the main process, and the second belongs to the subprocess.
\code{.Last.error} also includes a stack trace, that includes both the main R process and the subprocess:
The top part of the trace contains the frames in the main process, and the bottom part contains the frames in the subprocess, starting with the anonymous function.
}
\subsection{Standard output and error}{
By default, the standard output and error of the child is lost, but you can request callr to redirect them to files, and then inspect the files in the parent:
\if{html}{\out{
}}
With the \code{stdout} option, the standard output is collected and can be examined once the child process finished.
The \code{show = TRUE} options will also show the output of the child, as it is printed, on the console of the parent.
}
}
\subsection{Background R processes}{
\code{r_bg()} is similar to \code{r()} but it starts the R process in the background.
It returns an \code{r_process} R6 object, that provides a rich API:
\if{html}{\out{
}}\preformatted{rp <- callr::r_bg(function() Sys.sleep(.2))
rp
}\if{html}{\out{
}}\if{html}{\out{
#> PROCESS 'R', running, pid 58242.
}}
This is a list of all \code{r_process} methods:
\if{html}{\out{
}}
These include all methods of the \code{processx::process} superclass and the new \code{get_result()} method, to retrieve the R object returned by the function call.
Some of the handiest methods are:
\itemize{
\item \code{get_exit_status()} to query the exit status of a finished process.
\item \code{get_result()} to collect the return value of the R function call.
\item \code{interrupt()} to send an interrupt to the process. This is equivalent to a \code{CTRL+C} key press, and the R process might ignore it.
\item \code{is_alive()} to check if the process is alive.
\item \code{kill()} to terminate the process.
\item \code{poll_io()} to wait for any standard output, standard error, or the completion of the process, with a timeout.
\item \verb{read_*()} to read the standard output or error.
\item \code{suspend()} and \code{resume()} to stop and continue a process.
\item \code{wait()} to wait for the completion of the process, with a timeout.
}
}
\subsection{Multiple background R processes and \code{poll()}}{
Multiple background R processes are best managed with the \code{processx::poll()} function that waits for events (standard output/error or termination) from multiple processes.
It returns as soon as one process has generated an event, or if its timeout has expired.
The timeout is in milliseconds.
\if{html}{\out{
}}
}
\subsection{Persistent R sessions}{
\code{r_session} is another \code{processx::process} subclass that represents a persistent background R session:
\if{html}{\out{
}}
\code{r_session$run()} is a synchronous call, that works similarly to \code{r()}, but uses the persistent session.
\code{r_session$call()} starts the function call and returns immediately.
The \code{r_session$poll_process()} method or \code{processx::poll()} can then be used to wait for the completion or other events from one or more R sessions, R processes or other \code{processx::process} objects.
Once an R session is done with an asynchronous computation, its \code{poll_process()} method returns \code{"ready"} and the \code{r_session$read()} method can read out the result.
\if{html}{\out{
}}
}
\subsection{Running \verb{R CMD} commands}{
The \code{rcmd()} function calls an \verb{R CMD} command.
For example, you can call \verb{R CMD INSTALL}, \verb{R CMD check} or \verb{R CMD config} this way:
\if{html}{\out{
}}
This returns a list with three components: the standard output, the standard error, and the exit (status) code of the \verb{R CMD} command.
}
\subsection{Code of Conduct}{
Please note that the callr project is released with a
\href{https://callr.r-lib.org/CODE_OF_CONDUCT.html}{Contributor Code of Conduct}.
By contributing to this project, you agree to abide by its terms.
}
}
\seealso{
Useful links:
\itemize{
\item \url{https://callr.r-lib.org}
\item \url{https://github.com/r-lib/callr#readme}
\item Report bugs at \url{https://github.com/r-lib/callr/issues}
}
}
\author{
\strong{Maintainer}: Gábor Csárdi \email{csardi.gabor@gmail.com} (\href{https://orcid.org/0000-0001-7098-9676}{ORCID}) [copyright holder]
Authors:
\itemize{
\item Winston Chang
}
Other contributors:
\itemize{
\item Posit Software, PBC [copyright holder, funder]
\item Mango Solutions [copyright holder, funder]
}
}
\keyword{internal}
callr/man/add_hook.Rd 0000644 0001762 0000144 00000001336 14326534733 014176 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/hook.R
\name{add_hook}
\alias{add_hook}
\title{Add a user hook to be executed before launching an R subprocess}
\usage{
add_hook(...)
}
\arguments{
\item{...}{Named argument specifying a hook function to add, or \code{NULL} to
delete the named hook.}
}
\value{
\code{add_hook} is called for its side-effects.
}
\description{
This function allows users of \code{callr} to specify functions that get invoked
whenever an R session is launched. The function can modify the environment
variables and command line arguments.
}
\details{
The prototype of the hook function is \verb{function (options)}, and it is
expected to return the modified \code{options}.
}
callr/man/r_process_options.Rd 0000644 0001762 0000144 00000001473 14143453135 016173 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/options.R
\name{r_process_options}
\alias{r_process_options}
\title{Create options for an \link{r_process} object}
\usage{
r_process_options(...)
}
\arguments{
\item{...}{Options to override, named arguments.}
}
\value{
A list of options.
\code{r_process_options()} creates a set of options to initialize a new
object from the \code{r_process} class. Its arguments must be named, the
names are used as option names. The options correspond to (some of)
the arguments of the \code{\link[=r]{r()}} function. At least the \code{func} option must be
specified, this is the R function to run in the background.
}
\description{
Create options for an \link{r_process} object
}
\examples{
## List all options and their default values:
r_process_options()
}
callr/man/default_repos.Rd 0000644 0001762 0000144 00000001072 14143453135 015250 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utils.R
\name{default_repos}
\alias{default_repos}
\title{Default value for the \code{repos} option in callr subprocesses}
\usage{
default_repos()
}
\value{
Named character vector, the default value of the \code{repos}
option in callr subprocesses.
}
\description{
callr sets the \code{repos} option in subprocesses, to make sure that
a CRAN mirror is set up. This is because the subprocess cannot bring
up the menu of CRAN mirrors for the user to choose from.
}
\examples{
default_repos()
}
callr/man/r.Rd 0000644 0001762 0000144 00000023426 14330454562 012667 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/eval.R, R/presets.R
\name{r}
\alias{r}
\alias{r_safe}
\title{Evaluate an expression in another R session}
\usage{
r(
func,
args = list(),
libpath = .libPaths(),
repos = default_repos(),
stdout = NULL,
stderr = NULL,
poll_connection = TRUE,
error = getOption("callr.error", "error"),
cmdargs = c("--slave", "--no-save", "--no-restore"),
show = FALSE,
callback = NULL,
block_callback = NULL,
spinner = show && interactive(),
system_profile = FALSE,
user_profile = "project",
env = rcmd_safe_env(),
timeout = Inf,
package = FALSE,
arch = "same",
...
)
r_safe(
func,
args = list(),
libpath = .libPaths(),
repos = default_repos(),
stdout = NULL,
stderr = NULL,
poll_connection = TRUE,
error = getOption("callr.error", "error"),
cmdargs = c("--slave", "--no-save", "--no-restore"),
show = FALSE,
callback = NULL,
block_callback = NULL,
spinner = show && interactive(),
system_profile = FALSE,
user_profile = "project",
env = rcmd_safe_env(),
timeout = Inf,
package = FALSE,
arch = "same",
...
)
}
\arguments{
\item{func}{Function object to call in the new R process.
The function should be self-contained and only refer to
other functions and use variables explicitly from other packages
using the \code{::} notation. By default the environment of the function
is set to \code{.GlobalEnv} before passing it to the child process.
(See the \code{package} option if you want to keep the environment.)
Because of this, it is good practice to create an anonymous
function and pass that to \code{callr}, instead of passing
a function object from a (base or other) package. In particular
\if{html}{\out{
}}\preformatted{r(.libPaths)
}\if{html}{\out{
}}
does not work, because \code{.libPaths} is defined in a special
environment, but
\if{html}{\out{
}}
works just fine.}
\item{args}{Arguments to pass to the function. Must be a list.}
\item{libpath}{The library path.}
\item{repos}{The \code{repos} option. If \code{NULL}, then no
\code{repos} option is set. This options is only used if
\code{user_profile} or \code{system_profile} is set \code{FALSE},
as it is set using the system or the user profile.}
\item{stdout}{The name of the file the standard output of
the child R process will be written to.
If the child process runs with the \code{--slave} option (the default),
then the commands are not echoed and will not be shown
in the standard output. Also note that you need to call \code{print()}
explicitly to show the output of the command(s).
IF \code{NULL} (the default), then standard output is not returned, but
it is recorded and included in the error object if an error happens.}
\item{stderr}{The name of the file the standard error of
the child R process will be written to.
In particular \code{message()} sends output to the standard
error. If nothing was sent to the standard error, then this file
will be empty. This argument can be the same file as \code{stdout},
in which case they will be correctly interleaved. If this is the
string \code{"2>&1"}, then standard error is redirected to standard output.
IF \code{NULL} (the default), then standard output is not returned, but
it is recorded and included in the error object if an error happens.}
\item{poll_connection}{Whether to have a control connection to
the process. This is used to transmit messages from the subprocess
to the main process.}
\item{error}{What to do if the remote process throws an error.
See details below.}
\item{cmdargs}{Command line arguments to pass to the R process.
Note that \code{c("-f", rscript)} is appended to this, \code{rscript}
is the name of the script file to run. This contains a call to the
supplied function and some error handling code.}
\item{show}{Logical, whether to show the standard output on the screen
while the child process is running. Note that this is independent
of the \code{stdout} and \code{stderr} arguments. The standard
error is not shown currently.}
\item{callback}{A function to call for each line of the standard
output and standard error from the child process. It works together
with the \code{show} option; i.e. if \code{show = TRUE}, and a
callback is provided, then the output is shown of the screen, and the
callback is also called.}
\item{block_callback}{A function to call for each block of the standard
output and standard error. This callback is not line oriented, i.e.
multiple lines or half a line can be passed to the callback.}
\item{spinner}{Whether to show a calming spinner on the screen while
the child R session is running. By default it is shown if
\code{show = TRUE} and the R session is interactive.}
\item{system_profile}{Whether to use the system profile file.}
\item{user_profile}{Whether to use the user's profile file.
If this is \code{"project"}, then only the profile from the working
directory is used, but the \code{R_PROFILE_USER} environment variable
and the user level profile are not. See also "Security considerations"
below.}
\item{env}{Environment variables to set for the child process.}
\item{timeout}{Timeout for the function call to finish. It can be a
\link[base:difftime]{base::difftime} object, or a real number, meaning seconds.
If the process does not finish before the timeout period expires,
then a \code{system_command_timeout_error} error is thrown. \code{Inf}
means no timeout.}
\item{package}{Whether to keep the environment of \code{func} when passing
it to the other package. Possible values are:
\itemize{
\item \code{FALSE}: reset the environment to \code{.GlobalEnv}. This is the default.
\item \code{TRUE}: keep the environment as is.
\item \code{pkg}: set the environment to the \code{pkg} package namespace.
}}
\item{arch}{Architecture to use in the child process, for multi-arch
builds of R. By default the same as the main process. See
\code{\link[=supported_archs]{supported_archs()}}. If it contains a forward or backward slash
character, then it is taken as the path to the R executable.
Note that on Windows you need the path to \code{Rterm.exe}.}
\item{...}{Extra arguments are passed to \code{\link[processx:run]{processx::run()}}.}
}
\value{
Value of the evaluated expression.
}
\description{
From \code{callr} version 2.0.0, \code{r()} is equivalent to \code{r_safe()}, and
tries to set up a less error prone execution environment. In particular:
\itemize{
\item Ensures that at least one reasonable CRAN mirror is set up.
\item Adds some command line arguments to avoid saving \code{.RData} files, etc.
\item Ignores the system and user profiles (by default).
\item Sets various environment variables: \code{CYGWIN} to avoid
warnings about DOS-style paths, \code{R_TESTS} to avoid issues
when \code{callr} is invoked from unit tests, \code{R_BROWSER}
and \code{R_PDFVIEWER} to avoid starting a browser or a PDF viewer.
See \code{\link[=rcmd_safe_env]{rcmd_safe_env()}}.
}
}
\details{
The \code{r()} function from before 2.0.0 is called \code{\link[=r_copycat]{r_copycat()}} now.
}
\section{Error handling}{
\code{callr} handles errors properly. If the child process throws an
error, then \code{callr} throws an error with the same error message
in the main process.
The \code{error} expert argument may be used to specify a different
behavior on error. The following values are possible:
\itemize{
\item \code{error} is the default behavior: throw an error in the main process,
with a prefix and the same error message as in the subprocess.
\item \code{stack} also throws an error in the main process, but the error
is of a special kind, class \code{callr_error}, and it contains
both the original error object, and the call stack of the child,
as written out by \code{\link[utils:debugger]{utils::dump.frames()}}. This is now deprecated,
because the error thrown for \code{"error"} has the same information.
\item \code{debugger} is similar to \code{stack}, but in addition
to returning the complete call stack, it also start up a debugger
in the child call stack, via \code{\link[utils:debugger]{utils::debugger()}}.
}
The default error behavior can be also set using the \code{callr.error}
option. This is useful to debug code that uses \code{callr}.
callr uses parent errors, to keep the stacks of the main process and the
subprocess(es) in the same error object.
}
\section{Security considerations}{
\code{callr} makes a copy of the user's \code{.Renviron} file and potentially of
the local or user \code{.Rprofile}, in the session temporary
directory. Avoid storing sensitive information such as passwords, in
your environment file or your profile, otherwise this information will
get scattered in various files, at least temporarily, until the
subprocess finishes. You can use the keyring package to avoid passwords
in plain files.
}
\section{Transporting objects}{
\code{func} and \code{args} are copied to the child process by first serializing them
into a temporary file using \code{\link[=saveRDS]{saveRDS()}} and then loading them back into the
child session using \code{\link[=readRDS]{readRDS()}}. The same strategy is used to copy the result
of calling \code{func(args)} to the main session. Note that some objects, notably
those with \code{externalptr} type, won't work as expected after being
saved to a file and loaded back.
For performance reasons \code{compress=FALSE} is used when serializing with
\code{\link[=saveRDS]{saveRDS()}}, this can be disabled by setting
\code{options(callr.compress_transport = TRUE)}.
}
\examples{
\dontshow{if (FALSE) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf}
# Workspace is empty
r(function() ls())
# library path is the same by default
r(function() .libPaths())
.libPaths()
\dontshow{\}) # examplesIf}
}
\seealso{
Other callr functions:
\code{\link{r_copycat}()},
\code{\link{r_vanilla}()}
}
\concept{callr functions}
callr/man/rscript_process.Rd 0000644 0001762 0000144 00000032120 14564553726 015654 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/rscript.R
\name{rscript_process}
\alias{rscript_process}
\title{External \code{Rscript} process}
\description{
An \verb{Rscript script.R} command that runs in the background. This is an
R6 class that extends the \link[processx:process]{processx::process} class.
}
\examples{
\dontshow{if (FALSE) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf}
options <- rscript_process_options(script = "script.R")
rp <- rscript_process$new(options)
rp$wait()
rp$read_output_lines()
\dontshow{\}) # examplesIf}
}
\section{Super class}{
\code{\link[processx:process]{processx::process}} -> \code{rscript_process}
}
\section{Methods}{
\subsection{Public methods}{
\itemize{
\item \href{#method-rscript_process-new}{\code{rscript_process$new()}}
\item \href{#method-rscript_process-finalize}{\code{rscript_process$finalize()}}
\item \href{#method-rscript_process-clone}{\code{rscript_process$clone()}}
}
}
\if{html}{\out{
Inherited methods
}}
\describe{
\item{\code{options}}{A list of options created via
\code{\link[=rscript_process_options]{rscript_process_options()}}.}
}
\if{html}{\out{
}}
}
}
\if{html}{\out{}}
\if{html}{\out{}}
\if{latex}{\out{\hypertarget{method-rscript_process-finalize}{}}}
\subsection{Method \code{finalize()}}{
Clean up after an \code{Rsctipt} process, remove
temporary files.
\subsection{Usage}{
\if{html}{\out{
}}
}
}
\if{html}{\out{}}
\if{html}{\out{}}
\if{latex}{\out{\hypertarget{method-rscript_process-clone}{}}}
\subsection{Method \code{clone()}}{
The objects of this class are cloneable with this method.
\subsection{Usage}{
\if{html}{\out{
}}
\describe{
\item{\code{deep}}{Whether to make a deep clone.}
}
\if{html}{\out{
}}
}
}
}
callr/man/r_bg.Rd 0000644 0001762 0000144 00000013314 14564551363 013340 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/eval-bg.R
\name{r_bg}
\alias{r_bg}
\title{Evaluate an expression in another R session, in the background}
\usage{
r_bg(
func,
args = list(),
libpath = .libPaths(),
repos = default_repos(),
stdout = "|",
stderr = "|",
poll_connection = TRUE,
error = getOption("callr.error", "error"),
cmdargs = c("--slave", "--no-save", "--no-restore"),
system_profile = FALSE,
user_profile = "project",
env = rcmd_safe_env(),
supervise = FALSE,
package = FALSE,
arch = "same",
...
)
}
\arguments{
\item{func}{Function object to call in the new R process.
The function should be self-contained and only refer to
other functions and use variables explicitly from other packages
using the \code{::} notation. By default the environment of the function
is set to \code{.GlobalEnv} before passing it to the child process.
(See the \code{package} option if you want to keep the environment.)
Because of this, it is good practice to create an anonymous
function and pass that to \code{callr}, instead of passing
a function object from a (base or other) package. In particular
\if{html}{\out{
}}\preformatted{r(.libPaths)
}\if{html}{\out{
}}
does not work, because \code{.libPaths} is defined in a special
environment, but
\if{html}{\out{
}}
works just fine.}
\item{args}{Arguments to pass to the function. Must be a list.}
\item{libpath}{The library path.}
\item{repos}{The \code{repos} option. If \code{NULL}, then no
\code{repos} option is set. This options is only used if
\code{user_profile} or \code{system_profile} is set \code{FALSE},
as it is set using the system or the user profile.}
\item{stdout}{The name of the file the standard output of
the child R process will be written to.
If the child process runs with the \code{--slave} option (the default),
then the commands are not echoed and will not be shown
in the standard output. Also note that you need to call \code{print()}
explicitly to show the output of the command(s).
IF \code{NULL} (the default), then standard output is not returned, but
it is recorded and included in the error object if an error happens.}
\item{stderr}{The name of the file the standard error of
the child R process will be written to.
In particular \code{message()} sends output to the standard
error. If nothing was sent to the standard error, then this file
will be empty. This argument can be the same file as \code{stdout},
in which case they will be correctly interleaved. If this is the
string \code{"2>&1"}, then standard error is redirected to standard output.
IF \code{NULL} (the default), then standard output is not returned, but
it is recorded and included in the error object if an error happens.}
\item{poll_connection}{Whether to have a control connection to
the process. This is used to transmit messages from the subprocess
to the main process.}
\item{error}{What to do if the remote process throws an error.
See details below.}
\item{cmdargs}{Command line arguments to pass to the R process.
Note that \code{c("-f", rscript)} is appended to this, \code{rscript}
is the name of the script file to run. This contains a call to the
supplied function and some error handling code.}
\item{system_profile}{Whether to use the system profile file.}
\item{user_profile}{Whether to use the user's profile file.
If this is \code{"project"}, then only the profile from the working
directory is used, but the \code{R_PROFILE_USER} environment variable
and the user level profile are not. See also "Security considerations"
below.}
\item{env}{Environment variables to set for the child process.}
\item{supervise}{Whether to register the process with a supervisor. If \code{TRUE},
the supervisor will ensure that the process is killed when the R process
exits.}
\item{package}{Whether to keep the environment of \code{func} when passing
it to the other package. Possible values are:
\itemize{
\item \code{FALSE}: reset the environment to \code{.GlobalEnv}. This is the default.
\item \code{TRUE}: keep the environment as is.
\item \code{pkg}: set the environment to the \code{pkg} package namespace.
}}
\item{arch}{Architecture to use in the child process, for multi-arch
builds of R. By default the same as the main process. See
\code{\link[=supported_archs]{supported_archs()}}. If it contains a forward or backward slash
character, then it is taken as the path to the R executable.
Note that on Windows you need the path to \code{Rterm.exe}.}
\item{...}{Extra arguments are passed to the \link[processx:process]{processx::process}
constructor.}
}
\value{
An \code{r_process} object, which inherits from \link{process},
so all \code{process} methods can be called on it, and in addition it also
has a \code{get_result()} method to collect the result.
}
\description{
Starts evaluating an R function call in a background R process, and
returns immediately.
Use \code{p$get_result()} to collect the result or to throw an error
if the background computation failed.
}
\section{Security considerations}{
\code{callr} makes a copy of the user's \code{.Renviron} file and potentially of
the local or user \code{.Rprofile}, in the session temporary
directory. Avoid storing sensitive information such as passwords, in
your environment file or your profile, otherwise this information will
get scattered in various files, at least temporarily, until the
subprocess finishes. You can use the keyring package to avoid passwords
in plain files.
}
\examples{
\dontshow{if (FALSE) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf}
rx <- r_bg(function() 1 + 2)
# wait until it is done
rx$wait()
rx$is_alive()
rx$get_result()
\dontshow{\}) # examplesIf}
}
callr/man/rcmd_copycat.Rd 0000644 0001762 0000144 00000003750 14143453135 015070 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/rcmd.R
\name{rcmd_copycat}
\alias{rcmd_copycat}
\title{Call and \verb{R CMD} command, while mimicking the current R session}
\usage{
rcmd_copycat(
cmd,
cmdargs = character(),
libpath = .libPaths(),
repos = getOption("repos"),
env = character(),
...
)
}
\arguments{
\item{cmd}{Command to run. See \code{R --help} from the command
line for the various commands. In the current version of R (3.2.4)
these are: \code{BATCH}, \code{COMPILE}, \code{SHLIB}, \code{INSTALL}, \code{REMOVE}, \code{build},
\code{check}, \code{LINK}, \code{Rprof}, \code{Rdconv}, \code{Rd2pdf}, \code{Rd2txt}, \code{Stangle},
\code{Sweave}, \code{Rdiff}, \code{config}, \code{javareconf}, \code{rtags}.}
\item{cmdargs}{Command line arguments.}
\item{libpath}{The library path.}
\item{repos}{The \code{repos} option. If \code{NULL}, then no
\code{repos} option is set. This options is only used if
\code{user_profile} or \code{system_profile} is set \code{FALSE},
as it is set using the system or the user profile.}
\item{env}{Environment variables to set for the child process.}
\item{...}{Additional arguments are passed to \code{\link[=rcmd]{rcmd()}}.}
}
\description{
This function is similar to \code{\link[=rcmd]{rcmd()}}, but it has slightly different
defaults:
\itemize{
\item The \code{repos} options is unchanged.
\item No extra environment variables are defined.
}
}
\section{Security considerations}{
\code{callr} makes a copy of the user's \code{.Renviron} file and potentially of
the local or user \code{.Rprofile}, in the session temporary
directory. Avoid storing sensitive information such as passwords, in
your environment file or your profile, otherwise this information will
get scattered in various files, at least temporarily, until the
subprocess finishes. You can use the keyring package to avoid passwords
in plain files.
}
\seealso{
Other R CMD commands:
\code{\link{rcmd_bg}()},
\code{\link{rcmd}()}
}
\concept{R CMD commands}
callr/man/rcmd_bg.Rd 0000644 0001762 0000144 00000006213 14143453135 014013 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/rcmd-bg.R
\name{rcmd_bg}
\alias{rcmd_bg}
\title{Run an \verb{R CMD} command in the background}
\usage{
rcmd_bg(
cmd,
cmdargs = character(),
libpath = .libPaths(),
stdout = "|",
stderr = "|",
poll_connection = TRUE,
repos = default_repos(),
system_profile = FALSE,
user_profile = "project",
env = rcmd_safe_env(),
wd = ".",
supervise = FALSE,
...
)
}
\arguments{
\item{cmd}{Command to run. See \code{R --help} from the command
line for the various commands. In the current version of R (3.2.4)
these are: \code{BATCH}, \code{COMPILE}, \code{SHLIB}, \code{INSTALL}, \code{REMOVE}, \code{build},
\code{check}, \code{LINK}, \code{Rprof}, \code{Rdconv}, \code{Rd2pdf}, \code{Rd2txt}, \code{Stangle},
\code{Sweave}, \code{Rdiff}, \code{config}, \code{javareconf}, \code{rtags}.}
\item{cmdargs}{Command line arguments.}
\item{libpath}{The library path.}
\item{stdout}{Optionally a file name to send the standard output to.}
\item{stderr}{Optionally a file name to send the standard error to.
It may be the same as \code{stdout}, in which case standard error is
redirected to standard output. It can also be the special string
\code{"2>&1"}, in which case standard error will be redirected to standard
output.}
\item{poll_connection}{Whether to have a control connection to
the process. This is used to transmit messages from the subprocess
to the parent.}
\item{repos}{The \code{repos} option. If \code{NULL}, then no
\code{repos} option is set. This options is only used if
\code{user_profile} or \code{system_profile} is set \code{FALSE},
as it is set using the system or the user profile.}
\item{system_profile}{Whether to use the system profile file.}
\item{user_profile}{Whether to use the user's profile file.
If this is \code{"project"}, then only the profile from the working
directory is used, but the \code{R_PROFILE_USER} environment variable
and the user level profile are not. See also "Security considerations"
below.}
\item{env}{Environment variables to set for the child process.}
\item{wd}{Working directory to use for running the command. Defaults
to the current working directory.}
\item{supervise}{Whether to register the process with a supervisor. If \code{TRUE},
the supervisor will ensure that the process is killed when the R process
exits.}
\item{...}{Extra arguments are passed to the \link[processx:process]{processx::process}
constructor.}
}
\value{
It returns a \link{process} object.
}
\description{
The child process is started in the background, and the function
return immediately.
}
\section{Security considerations}{
\code{callr} makes a copy of the user's \code{.Renviron} file and potentially of
the local or user \code{.Rprofile}, in the session temporary
directory. Avoid storing sensitive information such as passwords, in
your environment file or your profile, otherwise this information will
get scattered in various files, at least temporarily, until the
subprocess finishes. You can use the keyring package to avoid passwords
in plain files.
}
\seealso{
Other R CMD commands:
\code{\link{rcmd_copycat}()},
\code{\link{rcmd}()}
}
\concept{R CMD commands}
callr/man/new_callr_crash_error.Rd 0000644 0001762 0000144 00000001212 14330431133 016737 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/error.R
\name{new_callr_crash_error}
\alias{new_callr_crash_error}
\title{Create an error object}
\usage{
new_callr_crash_error(out, msg = NULL)
}
\arguments{
\item{out}{The object returned by \code{\link[=run]{run()}}.}
\item{msg}{An extra message to add to the error message.}
}
\description{
There are two kinds of errors, both have class \code{callr_error}:
\enumerate{
\item the first one is thrown after a timeout: \code{callr_timeout_error}.
\item the second one is thrown after an R error (in the other session):
\code{callr_status_error}.
}
}
\keyword{internal}
callr/man/rcmd_process_options.Rd 0000644 0001762 0000144 00000001656 14143453135 016662 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/options.R
\name{rcmd_process_options}
\alias{rcmd_process_options}
\title{Create options for an \link{rcmd_process} object}
\usage{
rcmd_process_options(...)
}
\arguments{
\item{...}{Options to override, named arguments.}
}
\value{
A list of options.
\code{rcmd_process_options()} creates a set of options to initialize a new
object from the \code{rcmd_process} class. Its arguments must be named, the
names are used as option names. The options correspond to (some of)
the arguments of the \code{\link[=rcmd]{rcmd()}} function. At least the \code{cmd} option must
be specified, to select the \verb{R CMD} subcommand to run. Typically
\code{cmdargs} is specified as well, to supply more arguments to \verb{R CMD}.
}
\description{
Create options for an \link{rcmd_process} object
}
\examples{
## List all options and their default values:
rcmd_process_options()
}
callr/man/roxygen/ 0000755 0001762 0000144 00000000000 14326534733 013627 5 ustar ligges users callr/man/roxygen/meta.R 0000644 0001762 0000144 00000001115 14326534733 014676 0 ustar ligges users if (exists(".knitr_asciicast_process", envir = .GlobalEnv)) {
rm(list = ".knitr_asciicast_process", envir = .GlobalEnv)
}
asciicast::init_knitr_engine(
echo = TRUE,
echo_input = FALSE,
timeout = as.integer(Sys.getenv("ASCIICAST_TIMEOUT", 10)),
startup = quote(options(cli.num_colors = 256))
)
knitr::opts_chunk$set(
asciicast_knitr_output = "html",
asciicast_include_style = FALSE,
cache = TRUE,
cache.path = file.path(getwd(), "man/_cache/"),
fig.path = file.path(getwd(), "man/figures"),
error = TRUE
)
list(
markdown = TRUE,
restrict_image_formats = TRUE
)
callr/man/r_copycat.Rd 0000644 0001762 0000144 00000006260 14326533425 014407 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/presets.R
\name{r_copycat}
\alias{r_copycat}
\title{Run an R process that mimics the current R process}
\usage{
r_copycat(
func,
args = list(),
libpath = .libPaths(),
repos = getOption("repos"),
cmdargs = "--slave",
system_profile = TRUE,
user_profile = TRUE,
env = character(),
...
)
}
\arguments{
\item{func}{Function object to call in the new R process.
The function should be self-contained and only refer to
other functions and use variables explicitly from other packages
using the \code{::} notation. By default the environment of the function
is set to \code{.GlobalEnv} before passing it to the child process.
(See the \code{package} option if you want to keep the environment.)
Because of this, it is good practice to create an anonymous
function and pass that to \code{callr}, instead of passing
a function object from a (base or other) package. In particular
\if{html}{\out{
}}\preformatted{r(.libPaths)
}\if{html}{\out{
}}
does not work, because \code{.libPaths} is defined in a special
environment, but
\if{html}{\out{
}}
works just fine.}
\item{args}{Arguments to pass to the function. Must be a list.}
\item{libpath}{The library path.}
\item{repos}{The \code{repos} option. If \code{NULL}, then no
\code{repos} option is set. This options is only used if
\code{user_profile} or \code{system_profile} is set \code{FALSE},
as it is set using the system or the user profile.}
\item{cmdargs}{Command line arguments to pass to the R process.
Note that \code{c("-f", rscript)} is appended to this, \code{rscript}
is the name of the script file to run. This contains a call to the
supplied function and some error handling code.}
\item{system_profile}{Whether to use the system profile file.}
\item{user_profile}{Whether to use the user's profile file.
If this is \code{"project"}, then only the profile from the working
directory is used, but the \code{R_PROFILE_USER} environment variable
and the user level profile are not. See also "Security considerations"
below.}
\item{env}{Environment variables to set for the child process.}
\item{...}{Additional arguments are passed to \code{\link[=r]{r()}}.}
}
\description{
Differences to \code{\link[=r]{r()}}:
\itemize{
\item No extra repositories are set up.
\item The \code{--no-save}, \code{--no-restore}
command line arguments are not used. (But \code{--slave} still is.)
\item The system profile and the user profile are loaded.
\item No extra environment variables are set up.
}
}
\section{Security considerations}{
\code{callr} makes a copy of the user's \code{.Renviron} file and potentially of
the local or user \code{.Rprofile}, in the session temporary
directory. Avoid storing sensitive information such as passwords, in
your environment file or your profile, otherwise this information will
get scattered in various files, at least temporarily, until the
subprocess finishes. You can use the keyring package to avoid passwords
in plain files.
}
\seealso{
Other callr functions:
\code{\link{r_vanilla}()},
\code{\link{r}()}
}
\concept{callr functions}
callr/man/convert_and_check_my_args.Rd 0000644 0001762 0000144 00000001526 14143453135 017600 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/check.R
\name{convert_and_check_my_args}
\alias{convert_and_check_my_args}
\title{Convert and check function arguments}
\usage{
convert_and_check_my_args(options)
}
\arguments{
\item{options}{List of options.}
}
\description{
This function is used for all variants of \code{r} and \code{rcmd}. An argument
name is only used to refer to one kind of object, to make this possible.
}
\details{
The benefit of having a single \code{options} object is to avoid passing
around a lot of arguments all the time.
The benefit of making this object internal (i.e. that the \code{r}, etc.
functions have multiple arguments instead of a single \code{options} list),
is that documentation and usage is more user friendly (e.g. command-
completion works in the editor.
}
\keyword{internal}
callr/man/rscript_process_options.Rd 0000644 0001762 0000144 00000001540 14143453135 017413 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/options.R
\name{rscript_process_options}
\alias{rscript_process_options}
\title{Create options for an \link{rscript_process} object}
\usage{
rscript_process_options(...)
}
\arguments{
\item{...}{Options to override, named arguments.}
}
\value{
A list of options.
\code{rscript_process_options()} creates a set of options to initialize a new
object from the \code{rscript_process} class. Its arguments must be named,
the names are used as option names. The options correspond to (some of)
the arguments of the \code{\link[=rscript]{rscript()}} function. At least the \code{script} option
must be specified, the script file to run.
}
\description{
Create options for an \link{rscript_process} object
}
\examples{
## List all options and their default values:
rscript_process_options()
}
callr/man/get_result.Rd 0000644 0001762 0000144 00000001462 14564551567 014613 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/result.R
\name{get_result}
\alias{get_result}
\title{Read the result object from the output file, or the error}
\usage{
get_result(output, options)
}
\arguments{
\item{output}{List of the output object from \code{\link[=run]{run()}} and
the name of the result file to read. For the error file,
\code{.error} is appended to this.}
\item{options}{The context, including all parameters.}
}
\value{
If no error happened, the result is returned. Otherwise
we handle the error.
}
\description{
Even if an error happens, the output file might still exist,
because \code{\link[=saveRDS]{saveRDS()}} creates the file before evaluating its object
argument. So we need to check for the error file to decide
if an error happened.
}
\keyword{internal}
callr/man/figures/ 0000755 0001762 0000144 00000000000 14521175632 013574 5 ustar ligges users callr/man/figures/io-dark.svg 0000644 0001762 0000144 00000002346 14521175632 015650 0 ustar ligges users