Skip to content

Commit 1c3b0b4

Browse files
committed
Use project root dir as script's cwd
1 parent f645604 commit 1c3b0b4

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

crates/assistant_scripting/src/sandbox_preamble.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ io.open = sb_io_open
3737
-- Add the sandboxed io library to the sandbox environment
3838
-- sandbox.io = io -- Uncomment this line to re-enable sandboxed file I/O.
3939

40-
4140
-- Load the script with the sandbox environment
4241
local user_script_fn, err = load(user_script, nil, "t", sandbox)
4342

crates/assistant_scripting/src/session.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,14 @@ impl ScriptSession {
119119
let lua = Lua::new();
120120
lua.set_memory_limit(2 * 1024 * 1024 * 1024)?; // 2 GB
121121
let globals = lua.globals();
122+
123+
// Use the project root dir as the script's current working dir.
124+
if let Some(root_dir) = &root_dir {
125+
if let Some(root_dir) = root_dir.to_str() {
126+
globals.set("cwd", root_dir)?;
127+
}
128+
}
129+
122130
globals.set(
123131
"sb_print",
124132
lua.create_function({

0 commit comments

Comments
 (0)