Skip to content
Runtime

How to run Julia code in a sandbox

Install Julia in a Linux microVM with juliaup or the official tarball. Write the script, then 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 snapshot. Each sandbox is a Firecracker microVM that runs Ubuntu 24.04.5 with curl and sudo, so Julia's official installer works unchanged. A snapshot keeps the sandbox's files, including packages that are already precompiled, while you have credit. A sandbox started from it skips the install (snapshots and forks). Julia 1.13.2 was the current stable release on 26 October 2026.

Ways to install Julia

Julia is not in the default image. Ubuntu 24.04 (noble) has no julia package. Ubuntu's archive indexes for noble had none on 26 October 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.2) julia-1.13.2-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 prompts. Every setting keeps its default value (juliaup). For the sandbox user, the default location is ~/.juliaup, and HOME is /workspace.

Run a script

Install with juliaup. Then run the program with its full path, so no shell startup file is needed. The array form passes the arguments directly 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. Set timeoutMs above the 60-second default. Do not guess a low value.
  • Threads: julia --threads=auto uses the sandbox's cores. A sandbox can burst up to its vcpu count. It 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 this once with the network on. Snapshot the sandbox. 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 that only it holds (pricing). A fork goes further. It copies a running sandbox, with its memory and processes. A Julia session that has already compiled your functions can be copied 1 to 100 times simultaneously.

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.2-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.2/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. An account without credit stores its first three images at no charge (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 new accounts get 100 free hours of a 1 GB machine in their first 30 days. No payment card is needed.

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

Sources

Checked 26 October 2026.

Facts on this page were checked on 26 October 2026.

Related.

100 free hoursin your first 30 days.

of a 1 GB machine

  • No credit card
  • Four sandboxes at once, 2 vCPU and 4 GiB each
  • Then prepaid credit from $10, no plan fee
Start free, no card
Start free, no card