Sunday, June 28, 2026

Migrating from Tck 8.6 to 9+

Legacy Tcl & Gnocl Package Loading Fixes

Problem

The default interpreter on your system is Tcl 9.0 (/usr/local/bin/tclsh). However, the Gnocl package is only compiled for Tcl 8.x. When running scripts, if they are executed directly using tclsh script.tcl (or if your shell uses the default tclsh), they will run under Tcl 9.0 and fail to load Gnocl.

 

Additionally, shell shebang restart blocks (# !/bin/sh ... exec tclsh) only restart under Tcl 8.6 if executed as ./script.tcl from the shell. If you execute them directly as tclsh script.tcl, Tcl treats the shell shebang as a comment, bypasses it, and runs with Tcl 9.0, leading to the same package load error.

Solutions Implemented

  1. Interpreter Redirection Changed the shell restart blocks to explicitly point to /usr/bin/tclsh8.6

  2. Robust Runtime Version Check Added a runtime Tcl version check inside  and . If either file is loaded or run directly by an incompatible Tcl version (like Tcl 9.0), it will immediately restart itself under tclsh8.6 with full stdout and stderr redirection:

    tcl
    if {[info tclversion] ne "8.6"} {
    exec tclsh8.6 $argv0 {*}$argv >@ stdout 2>@ stderr
    exit
    }


No comments:

Migrating from Tck 8.6 to 9+