Runtime

How to run Julia code in a sandbox

Install Julia in a Linux microVM with juliaup or the official tarball, write the script there, and run it with julia and a time limit.

On Runtime you install Julia and its packages once, snapshot the machine, and start every later run from that point. Each sandbox is a Firecracker microVM running Ubuntu 24.04.5 with curl and sudo, so Julia's official installer works unchanged. A snapshot keeps the sandbox's files, including packages already precompiled, for 1 to 365 days, and a sandbox started from it skips the install (snapshots and forks). Julia 1.13.0 was the current stable release on 25 September 2026.

Ways to install Julia

Julia is not in the default image, and Ubuntu 24.04 (noble) has no julia package: packages.ubuntu.com answered "No such package" on 25 September 2026. Use one of Julia's own channels:

Method Command Where it puts julia
juliaup, the official installer the install.julialang.org script with --yes /workspace/.juliaup/bin/julia
The official tarball (1.13.0) julia-1.13.0-linux-x86_64.tar.gz from julialang-s3.julialang.org wherever you unpack it
The official Docker image julia:1.13 on Docker Hub on PATH in that image

--yes runs juliaup's installer without questions, with every setting at its default (juliaup). As the sandbox user, the default is ~/.juliaup, and HOME is /workspace.

Run a script

Install with juliaup, then run the program with its full path so no shell start-up file is needed. The array form passes the arguments straight to Julia.

TypeScriptimport { Sandbox } from "withruntime";const script = `fib(n) = n < 2 ? n : fib(n - 1) + fib(n - 2)println(join(fib.(0:15), " "))`;const julia = "/workspace/.juliaup/bin/julia";await using sbx = await Sandbox.create({ diskMiB: 8192, timeoutSeconds: 900, onLeaseEnd: "stop" });await sbx.exec("curl -fsSL https://install.julialang.org | sh -s -- --yes", {  check: true,  timeoutMs: 600_000,});await sbx.network.set({ internet: false });await sbx.files.write("/workspace/fib.jl", script);const run = await sbx.exec([julia, "--startup-file=no", "fib.jl"], { timeoutMs: 120_000 });console.log(run.exitCode, run.timedOut, run.stdout);
Pythonfrom withruntime import Sandboxscript = """fib(n) = n < 2 ? n : fib(n - 1) + fib(n - 2)println(join(fib.(0:15), " "))"""julia = "/workspace/.juliaup/bin/julia"with Sandbox.create(disk_mib=8192, timeout_seconds=900, on_lease_end="stop") as sbx:    sbx.exec("curl -fsSL https://install.julialang.org | sh -s -- --yes", check=True, timeout_ms=600_000)    sbx.network.set(internet=False)    sbx.files.write("/workspace/fib.jl", script)    run = sbx.exec([julia, "--startup-file=no", "fib.jl"], timeout_ms=120_000)    print(run.exit_code, run.timed_out, run.stdout)
  • Give Julia room. Ask for more than the default 4 GiB disk, which has about 2.5 GiB free (the sandbox environment).
  • Give the first run time. Julia compiles code the first time it runs, so set timeoutMs above the 60-second default rather than guessing low.
  • Threads: julia --threads=auto uses the sandbox's cores. A sandbox bursts up to its vcpu count and is billed for the CPU it uses.

Install packages once and snapshot the result

Pkg.add downloads from Julia's package servers and precompiles into ~/.julia. Do it once with the network on, snapshot the sandbox, and start each run from the snapshot with the network off.

TypeScriptimport { Runtime, Sandbox } from "withruntime";const runtime = new Runtime();const julia = "/workspace/.juliaup/bin/julia";await using base = await Sandbox.create({ diskMiB: 8192, timeoutSeconds: 1800 });await base.exec("curl -fsSL https://install.julialang.org | sh -s -- --yes", {  check: true,  timeoutMs: 600_000,});await base.exec([julia, "-e", 'using Pkg; Pkg.add(["DataFrames", "CSV"]); Pkg.precompile()'], {  check: true,  timeoutMs: 1_800_000,});const snapshot = await base.snapshot({ name: "julia-data", retentionDays: 30 });// Each job, later:await using job = await runtime.sandboxes.create({  snapshot: snapshot.id,  network: { internet: false },});const run = await job.exec([julia, "-e", "using DataFrames; println(DataFrame(a = 1:3))"], {  timeoutMs: 300_000,});console.log(run.stdout);

A snapshot is billed as storage on the blocks it alone holds (pricing). A fork goes further: it copies a running sandbox with its memory and processes, so a Julia session that has already compiled your functions can be copied 1 to 10 times at once.

Bake Julia into an image

An image makes Julia part of every sandbox you create from it. The recipe's commands run as root, so unpack the official tarball into /opt and link it onto PATH:

Pythonfrom withruntime import Runtimeurl = "https://julialang-s3.julialang.org/bin/linux/x64/1.13/julia-1.13.0-linux-x86_64.tar.gz"runtime = Runtime()runtime.images.build(name="julia", recipe={"commands": [    f"curl -fsSL {url} | tar -xz -C /opt",    "ln -s /opt/julia-1.13.0/bin/julia /usr/local/bin/julia",]})with runtime.sandboxes.create(image="julia", network={"internet": False}) as sbx:    print(sbx.exec(["julia", "--version"]).stdout)

Or start from the official image as it is: runtime.images.build({ name: "julia-official", image: "julia:1.13" }). Building an image is free, and the free trial stores your first three free (custom images).

What it costs

A 2 vCPU, 4 GiB sandbox costs $0.08 an hour with both cores busy and $0.03125 an hour while it waits, because Runtime bills measured CPU at $0.025 per vCPU-hour and memory at $0.0075 per GiB-hour (pricing). New accounts get 50 free sandbox hours, no card.

See also a data analysis agent, sandbox snapshots and running untrusted LLM code.

Sources

Checked 25 September 2026.

Facts on this page were checked on 25 September 2026.