18 · Modules
Foreign dependencies and locks
Declare dependencies once at file scope. Provider names must be explicitly imported; aliases select the same environment as their original provider. Native imports still choose the symbols used inside each fragment.
On this page
Declare dependencies once at file scope. Provider names must be explicitly imported; aliases select the same environment as their original provider. Native imports still choose the symbols used inside each fragment.
Run locally with the matching plugin and runtime. These examples do not run in the browser playground.
Foreign dependencies and locks.
// Prepare once: zolo install examples/features/14-modules/47-unified-dependencies.zolo
// Requires Rust, C++/vcpkg and the JVM/Kotlin provider toolchains for preparation.
// parity-timeout-ms:300000
use plugin rust::{rust as rs}
use plugin native::{cpp}
use plugin jvm::{kotlin as kt}
deps {
rs::serde_json = "1.0.145"
cpp::fmt = { version = "11.0.2", default_features = true }
kt::"com.google.guava:guava" = "33.4.0-jre"
}
extern rs fn answer() -> int {
let value: serde_json::Value = serde_json::from_str(r#"{"answer":42}"#).unwrap();
value["answer"].as_i64().unwrap()
}
extern cpp fn formatted(value: int) -> str {
#include <fmt/format.h>
return fmt::format("exact {}", value);
}
extern kt fn join(values: [str]) -> str {
import com.google.common.base.Joiner
return Joiner.on(", ").join(values.asIterable())
}
print(answer())
print(formatted(9007199254740993))
print(join(["Kotlin", "Maven", "Zolo"]))
// expected:
// 42
// exact 9007199254740993
// Kotlin, Maven, Zolo
Requires the Zolo CLI/host — open in the playground or run locally.
Installation policy
auto prepares missing dependencies before authored execution. manual requires a prepared environment and reports the install command when one is missing. offline uses matching local artifacts only. Opening a source file in the editor never installs packages or executes its authored code.
Locks and offline execution
--frozen requires a matching lock and prohibits changes; it does not by itself prohibit downloading already locked artifacts. Combine --offline and --frozen to forbid network access and lock updates. Dependency versions below are illustrative exact pins, not recommendations for the latest releases.