summaryrefslogtreecommitdiff
path: root/src/luarocks_runtime.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/luarocks_runtime.zig')
-rw-r--r--src/luarocks_runtime.zig19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/luarocks_runtime.zig b/src/luarocks_runtime.zig
index 96b2e37..1611778 100644
--- a/src/luarocks_runtime.zig
+++ b/src/luarocks_runtime.zig
@@ -61,6 +61,19 @@ pub const LuarocksRuntime = struct {
self.layout.deinit();
self.allocator.destroy(self);
}
+
+ /// Wire one `lua_State` with the per-state half of the bootstrap: the
+ /// embedded luarocks searcher, the injected `luarocks.core.hardcoded`,
+ /// and the tree's `package.path`/`package.cpath` entries. `bootstrap`
+ /// runs this on its own state; each per-session interpreter (whose
+ /// lifetime is the session — see `extension_loader.zig`) gets the same
+ /// wiring so `require` resolves the staged `panto.so` and installed
+ /// rocks. Disk-side staging is process-level and NOT repeated here.
+ pub fn attachState(self: *LuarocksRuntime, L: *c.lua_State) !void {
+ try installEmbeddedSearcher(L, &self.modules);
+ try injectHardcoded(L, self.layout);
+ try configurePackagePaths(self.allocator, L, self.layout);
+ }
};
/// Errors surfaced by the bootstrap pipeline. The `Luarocks*` variants
@@ -164,9 +177,7 @@ pub fn bootstrap(
self.modules.putAssumeCapacityNoClobber(entry.name, entry.contents);
}
- try installEmbeddedSearcher(L, &self.modules);
- try injectHardcoded(L, layout);
- try configurePackagePaths(allocator, L, layout);
+ try self.attachState(L);
// Reconcile the batteries manifest. This may take a while on a
// fresh install; subsequent runs no-op. Runs in-process — we
@@ -457,7 +468,7 @@ const default_base_config =
\\# account_id_jwt_claim = "https://api.openai.com/auth"
\\
\\# Tool/extension availability (glob patterns). Empty allow = allow all.
- \\# [tools]
+ \\# [extensions]
\\# allow = ["std.*"]
\\# deny = []
\\