diff --git a/src/modules/punk/repl-999999.0a1.0.tm b/src/modules/punk/repl-999999.0a1.0.tm index a69a7742..066b0a44 100644 --- a/src/modules/punk/repl-999999.0a1.0.tm +++ b/src/modules/punk/repl-999999.0a1.0.tm @@ -3577,6 +3577,12 @@ namespace eval repl { switch -- $repltype { safe { interp create -safe -- code + #propagate tm list, auto_path, and package prefer to the safe code interp. + #-libunknown is not used because safe interps cannot source arbitrary files; + #the epoch copy below remains for cooperative use if libunknown is later + #adapted for safe interps (see TODO at line ~3634). + package require punk::lib + catch {punk::lib::interp_sync_package_paths code} code eval [list namespace eval ::punk::libunknown {}] catch { code eval [list set ::punk::libunknown::epoch $::punk::libunknown::epoch] diff --git a/src/modules/zzzload-999999.0a1.0.tm b/src/modules/zzzload-999999.0a1.0.tm index 506b7a1c..231ca65d 100644 --- a/src/modules/zzzload-999999.0a1.0.tm +++ b/src/modules/zzzload-999999.0a1.0.tm @@ -63,9 +63,15 @@ namespace eval zzzload { return $ver } if {$loader_tid eq ""} { - set loader_tid [thread::create -joinable -preserved] - #todo - set tcl::tm::list and ::auto_path in the loader thread to match the main thread. - #(startup process may have modified these paths) + #propagate tm list, auto_path, and package prefer to the loader thread + #so it can find the same packages as the parent interp. + if {![catch {package require punk::lib}]} { + set init_script [punk::lib::snapshot_package_paths] + set loader_tid [thread::create -joinable -preserved $init_script] + } else { + #punk::lib not available — fall back to bare thread + set loader_tid [thread::create -joinable -preserved] + } } if {![tsv::exists zzzload_pkg $pkgname]} { #puts stderr "zzzload pkg_require $pkgname"