Guide 47 of 53
Foreign dependencies and locks
One dependency declaration with explicit installation, frozen and offline policies.
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.
// 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, ZoloInstallation 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.
zolo install analysis.zolo
zolo install --frozen
zolo run analysis.zolo --offline --frozenLocks 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.
Ecosystem adapters¶
NuGet, Python packages, npm, Maven, Cargo, Go modules and vcpkg keep their ecosystem resolution semantics. Java/Kotlin share the JVM environment and JS/TS share Node. Prepared artifacts preserve runtime/native assets and integrity metadata; copying an executable does not automatically remove every runtime dependency.
Programming language integrations · Types across the boundary
DOCS / FEEDBACK
Did this page leave a question?
Tell us where the explanation lost you. Documentation is part of the language experience.