Skip to contents

Runs a program in a fresh Maxima process. Syntax or runtime failures stop with the original diagnostic. This checks one execution of randomized code; it does not prove every variant works on the target ONYX installation. The ONYX statistics libraries distrib, descriptive, and stats are loaded by default. Supply libraries to include others, such as draw. No R interface package for Maxima is required, but Maxima support uses the suggested packages processx, filelock, later, promises and openssl.

Usage

maxima_check(
  code,
  executable = maxima_default_executable(),
  timeout = getOption("rqti.maxima_timeout", 120),
  file = NULL,
  chunk = NULL,
  libraries = c("distrib", "descriptive", "stats"),
  outputs = FALSE
)

Arguments

code

A non-empty Maxima program.

executable

Maxima command name or full path to the command-line executable / Windows .bat or .cmd launcher. Defaults to option rqti.maxima, the current preview-console choice in a separate Knit session, or "maxima" on PATH. Explicit paths may contain spaces and Unicode; do not add shell quotes.

timeout

Maximum execution time in seconds. Defaults to option rqti.maxima_timeout, or 120 seconds (including library startup).

file, chunk

Optional source filename and chunk label for diagnostics.

libraries

Character vector of Maxima libraries to load first.

outputs

If TRUE, inspect the program's final string([...]) return value and return its named output types. Unsupported types are marked "unsupported"; maxima_variables() requires explicit declarations for them.

Value

Invisibly, TRUE on success, or a named type vector if outputs=TRUE.

Details

New global variables or functions left by the program produce a warning. Keep variables in block([a, b], ...) and declare functions with local(f) inside the block. Globals may force a restart on delivery servers that reuse Maxima instances, slowing down large exams. The check compares values and functions after loading libraries and after running the program; changes to existing definitions or other random variants may be missed.

Compiled library cache

Compiled libraries are shared with the local preview server across R sessions. On R >= 4.0, the cache is stored under tools::R_user_dir("rqti", "cache"). Set options(rqti.maxima_cache_dir = "/path/to/cache") to choose a directory, or options(rqti.maxima_cache_dir = FALSE) for a session-only cache. Earlier R versions use a session-only cache. Creation is lazy, when libraries are needed. Each calculation still uses a fresh process and temporary programs and results. Build-specific caches are protected by a cross-process lock; preview jobs wait asynchronously. Old builds and caches unused for 30 days are removed, and caches exceeding 64 MiB are discarded after use. Interrupted library loading discards the incomplete cache.