<div style="font-family: Arial, sans-serif; font-size: 14px;"><span>Package: tcl</span><div><span>Package: tk</span></div><div><br></div><div><span>I am having trouble running my TCL app with this structure /project/main.tcl, data.tcl, db.tcl, gui.tcl, file.sqlite.</span></div><div><span>The app functions fine as a single file. I broke it down into separate files to make maintaining it easier for future growth.</span></div><div><br></div><div><span>Note: I am learning to program so I am not sure how to diagnose the issue thoroughly.</span></div><div><span> I have been using Grok to help me understand what happened.</span></div><div><span> If I can do most of the work, through AI, without bothering a developer with my limitations, then I think it is a useful direction. My code could be incorrectly structured, so I explored this first.</span></div><div><span> After it didn't appear to be a code structure issue I began to suspect a deeper issue.</span></div><div><span> Since my error resolution skills are just emerging, I enlisted AI.</span></div><div><span> I have removed the markdown structure.</span></div><div><br></div><div><span>The Error begins after main.tcl begins to execute, the error starts with 'source "db.tcl"'. </span></div><div><br></div><div><span>[code]</span></div><div><span>/home/user/project-app/</span></div><div><span> ├── main.tcl</span></div><div><span> ├── db.tcl</span></div><div><span> ├── gui.tcl</span></div><div><span> ├── data.tcl</span></div><div><span> ├── file.sqlite</span></div><div><span>[/code]</span></div><div><br></div><div><span>Check with:</span></div><div><span> [code]$ ls -l /home/user/project-app/[/code]</span></div><div><span> The permissions for all of the .tcl files: -rw-rw-r--</span></div><div><span> The permissions for one of the files, file.sqlite: -rwxrwxr-x</span></div><div><span> I don't think this is an issue as 'tclsh' executes these scripts, they just need to be read/write accessible.</span></div><div><span> </span></div><div><span>Check if '/home' is mounted with 'noexec':</span></div><div><span> [code]bash</span></div><div><span> mount | grep /home[/code]</span></div><div><span> The home partition is not mounted with 'noexec'.</span></div><div><br></div><div><span>Everything passes until I get to checking tclsh 'Environement'. This is where it fails:</span></div><div><br></div><div><span>[code] </span></div><div><span>% tclsh -c "puts $tcl_version; package require Tk; puts $tk_version"</span></div><div><span>can't read "tk_version": no such variable</span></div><div><span>[/code]</span></div><div><br></div><div><span>The 'package require Tk' command failed silently (e.g., Tk is not installed or not found), so 'tk_version' was never set.</span></div><div><br></div><div><span>- Environment Variables:</span></div><div><span> Tcl/Tk relies on 'TCL_LIBRARY' and 'TK_LIBRARY' environment variables to find libraries. If these are unset or point to incorrect paths (e.g., across partitions), 'package require Tk' may fail.</span></div><div><span> </span></div><div><span>- Incomplete Output:</span></div><div><span> The error output doesn’t show 'tcl_version', which suggests tclsh may have failed before executing the full command or the output was truncated. This could happen if 'tclsh' itself is misconfigured.</span></div><div><span> </span></div><div><span>Running each command individually to verify the issue:</span></div><div><span>[code]</span></div><div><span>$ wish</span></div><div><span>% puts $tcl_version</span></div><div><span>8.6</span></div><div><span>% puts $tk_version</span></div><div><span>8.6</span></div><div><br></div><div><span>$ tclsh</span></div><div><span>% puts $tcl_version</span></div><div><span>8.6</span></div><div><span>% puts $tk_version</span></div><div><span>can't read "tk_version": no such variable</span></div><div><br></div><div><span>% puts $auto_path</span></div><div><span>/usr/share/tcltk/tcl8.6 /usr/share/tcltk /usr/lib /usr/local/lib/tcltk /usr/local/share/tcltk /usr/lib/tcltk/x86_64-linux-gnu /usr/lib/tcltk /usr/lib/tcltk/tcl8.6</span></div><div><span>[/code]</span></div><div><br></div><div><span>- 'puts $auto_path' lists directories where Tcl looks for packages (e.g., `/usr/lib/tcl8.6`, `/usr/lib/tk8.6`).</span></div><div><span>With Tk is missing, I checked for Tk libraries:</span></div><div><br></div><div><span>[code]</span></div><div><span>ls /usr/lib/tcltk/* /usr/lib/*tcl* /usr/local/lib/*tcl*</span></div><div><br></div><div><span>ls: cannot access '/usr/local/lib/*tcl*': No such file or directory</span></div><div><span> /usr/lib/tclConfig.sh /usr/lib/tclooConfig.sh</span></div><div><br></div><div><span>/usr/lib/tcl8.6:</span></div><div><span><a target="_blank" rel="noreferrer nofollow noopener" href="http://tclConfig.sh">tclConfig.sh</a> <a target="_blank" rel="noreferrer nofollow noopener" href="http://tclooConfig.sh">tclooConfig.sh</a></span></div><div><br></div><div><span>/usr/lib/tcltk:</span></div><div><span>sqlite3 TclCurl7.22.1 x86_64-linux-gnu</span></div><div><br></div><div><span>/usr/lib/tcltk/sqlite3:</span></div><div><span><a target="_blank" rel="noreferrer nofollow noopener" href="http://libtclsqlite3.la">libtclsqlite3.la</a> <a target="_blank" rel="noreferrer nofollow noopener" href="http://libtclsqlite3.so">libtclsqlite3.so</a> pkgIndex.tcl</span></div><div><br></div><div><span>/usr/lib/tcltk/TclCurl7.22.1:</span></div><div><span><a target="_blank" rel="noreferrer nofollow noopener" href="http://libTclCurl7.22.1.so">libTclCurl7.22.1.so</a> pkgIndex.tcl tclcurl.tcl</span></div><div><br></div><div><span>/usr/lib/tcltk/x86_64-linux-gnu:</span></div><div><span>tclreadline2.4.0 tclxml3.2 thread2.8.11 tk8.6 tls1.8.0 udp1.0.12</span></div><div><span>[/code]</span></div><div><br></div><div><span>If 'package require Tk' fails, (It doesn't) I check Tk installation anyway:</span></div><div><span>[code]</span></div><div><span>dpkg -l | grep tk</span></div><div><span>[/code]</span></div><div><br></div><div><span>Everything looks good with installation list.</span></div><div><span>- Cause: The 'tk_version' error likely stems from 'tclsh' not finding the Tk package, possibly due to library path issues or an incomplete Tk installation. The partitioned setup doesn’t directly cause this but may affect library access.</span></div><div><br></div><div><span>Step 1: Analyzing the `$auto_path` Output</span></div><div><span>The `$auto_path` output you provided is:</span></div><div><span>```</span></div><div><span>/usr/share/tcltk/tcl8.6 /usr/share/tcltk /usr/lib /usr/local/lib/tcltk /usr/local/share/tcltk /usr/lib/tcltk/x86_64-linux-gnu /usr/lib/tcltk /usr/lib/tcltk/tcl8.6 /usr/share/tcltk/tcllib2.0 /usr/share/tcltk/ttkthemes</span></div><div><span>```</span></div><div><span>- What This Means:</span></div><div><span> - '$auto_path' lists directories where Tcl searches for packages (e.g., Tk) when 'package require' is called.</span></div><div><span> - Key directories include:</span></div><div><span> - '/usr/share/tcltk/tcl8.6': Tcl 8.6 libraries.</span></div><div><span> - '/usr/lib/tcltk/x86_64-linux-gnu': Architecture-specific Tcl/Tk libraries.</span></div><div><span> - '/usr/lib/tcltk/tcl8.6': Tcl 8.6-specific libraries.</span></div><div><span> - '/usr/share/tcltk': General Tcl/Tk shared files.</span></div><div><span> - '/usr/share/tcltk/ttkthemes': Tk themes (for `ttk` widgets, used in your app’s search bar).</span></div><div><span> - Notably, '/usr/lib/tcltk/tk8.6' (or similar) is missing, which is where Tk’s package files (e.g., 'pkgIndex.tcl' for Tk) are typically located.</span></div><div><br></div><div><span>- Implications:</span></div><div><span> - The absence of a Tk-specific directory (e.g., '/usr/lib/tcltk/tk8.6') in '$auto_path' suggests that 'tclsh' may not find the Tk package, causing 'package require Tk' to fail and 'tk_version' to be undefined.</span></div><div><span> </span></div><div><span>Step 2: Why the '$tk_version' Error Occurred:</span></div><div><span>The error 'can't read "tk_version": no such variable` occurs because:</span></div><div><span>1. Tk Package Not Loaded:</span></div><div><span> - 'package require Tk' in 'tclsh' fails to load Tk, likely because the Tk package ('pkgIndex.tcl' and '<a target="_blank" rel="noreferrer nofollow noopener" href="http://libtk8.6.so">libtk8.6.so</a>') is not in '$auto_path' or not installed.</span></div><div><span> - Without Tk loaded, 'tk_version' is not defined, causing the error.</span></div><div><br></div><div><span>Check Tk library files:</span></div><div><span>[code]</span></div><div><span>$ ls /usr/lib/tcltk/tk* /usr/lib/*/tk* /usr/share/tcltk/tk*</span></div><div><br></div><div><span>ls: cannot access '/usr/lib/tcltk/tk*': No such file or directory</span></div><div><span> /usr/lib/tk8.6/tkConfig.sh /usr/lib/x86_64-linux-gnu/tkConfig.sh</span></div><div><br></div><div><span>/usr/lib/x86_64-linux-gnu/tk8.6:</span></div><div><span><a target="_blank" rel="noreferrer nofollow noopener" href="http://tkConfig.sh">tkConfig.sh</a></span></div><div><br></div><div><span>/usr/share/tcltk/tk8.6:</span></div><div><span>bgerror.tcl comdlg.tcl focus.tcl images mkpsenc.tcl optMenu.tcl scale.tcl tearoff.tcl tk.tcl</span></div><div><span>button.tcl console.tcl fontchooser.tcl listbox.tcl msgbox.tcl palette.tcl scrlbar.tcl text.tcl ttk</span></div><div><span>choosedir.tcl dialog.tcl iconlist.tcl megawidget.tcl msgs panedwindow.tcl spinbox.tcl tkAppInit.c unsupported.tcl</span></div><div><span>clrpick.tcl entry.tcl icons.tcl menu.tcl obsolete.tcl safetk.tcl tclIndex tkfbox.tcl xmfbox.tcl</span></div><div><span>[/code]</span></div><div><span>Expect to see '/usr/lib/tcltk/tk8.6' or similar, containing 'pkgIndex.tcl' and '<a target="_blank" rel="noreferrer nofollow noopener" href="http://libtk8.6.so">libtk8.6.so</a>'.</span></div><div><br></div><div><span>Check Tk Path:</span></div><div><span>[code]</span></div><div><span>$ find /usr/lib /usr/share -name "tk8.6" 2>/dev/null</span></div><div><br></div><div><span>/usr/lib/x86_64-linux-gnu/tk8.6</span></div><div><span>/usr/lib/tk8.6</span></div><div><span>/usr/lib/tcltk/x86_64-linux-gnu/tk8.6</span></div><div><span>/usr/share/doc/tk8.6</span></div><div><span>/usr/share/tcltk/tk8.6</span></div><div><span>[/code]</span></div><div><br></div><div><span>- Key Observations:</span></div><div><span> - No '/usr/lib/tcltk/tk': The directory '/usr/lib/tcltk/tk*' doesn’t exist, which is expected if Tk is installed in a different location (e.g., '/usr/lib/tk8.6' or '/usr/lib/x86_64-linux-gnu/tk8.6).</span></div><div><span> - '/usr/lib/tk8.6/tkConfig.sh': Contains Tk build configuration, not the runtime library ('<a target="_blank" rel="noreferrer nofollow noopener" href="http://libtk8.6.so">libtk8.6.so</a>') or package index ('pkgIndex.tcl').</span></div><div><span> - '/usr/lib/x86_64-linux-gnu/tk8.6/tkConfig.sh': Another Tk configuration file, likely for architecture-specific builds.</span></div><div><span> - '/usr/share/tcltk/tk8.6': Contains Tk’s Tcl scripts (e.g., 'tk.tcl', 'ttk/', 'tclIndex'), which are part of the Tk package. However, the critical runtime library ('<a target="_blank" rel="noreferrer nofollow noopener" href="http://libtk8.6.so">libtk8.6.so</a>') is missing from this output.</span></div><div><span> - Missing '<a target="_blank" rel="noreferrer nofollow noopener" href="http://libtk8.6.so">libtk8.6.so</a>': The Tk shared library, required for 'package require Tk', is not listed. It’s typically in '/usr/lib/x86_64-linux-gnu' or '/usr/lib/tcltk/tk8.6'.</span></div><div><span> </span></div><div><span>- '$auto_path' (from previous response):</span></div><div><span>Includes '/usr/share/tcltk/tk8.6' (where Tk scripts are) but not '/usr/lib/x86_64-linux-gnu' (where '<a target="_blank" rel="noreferrer nofollow noopener" href="http://libtk8.6.so">libtk8.6.so</a>' likely resides).</span></div><div><span>- Implications:</span></div><div><span> - The Tk package is partially installed: Tcl scripts are in '/usr/share/tcltk/tk8.6', but the runtime library ('<a target="_blank" rel="noreferrer nofollow noopener" href="http://libtk8.6.so">libtk8.6.so</a>') is missing or not in '$auto_path'.</span></div><div><span> - 'tclsh' fails to load Tk ('package require Tk') because it can’t find '<a target="_blank" rel="noreferrer nofollow noopener" href="http://libtk8.6.so">libtk8.6.so</a>' or 'pkgIndex.tcl' for Tk 8.6.</span></div><div><span> </span></div><div><span>Missing Library:</span></div><div><span> - The 'ls' output doesn’t show '<a target="_blank" rel="noreferrer nofollow noopener" href="http://libtk8.6.so">libtk8.6.so</a>', which is needed for Tk to load in 'tclsh'. It’s likely in '/usr/lib/x86_64-linux-gnu' but not listed due to the specific 'tk*' pattern in your 'ls' command.</span></div><div><span> </span></div><div><span>Locate '<a target="_blank" rel="noreferrer nofollow noopener" href="http://libtk8.6.so">libtk8.6.so</a>'</span></div><div><span>Check for the Tk library:</span></div><div><span>[code]</span></div><div><span>$ find /usr/lib /usr/share -name <a target="_blank" rel="noreferrer nofollow noopener" href="http://libtk8.6.so">libtk8.6.so</a> 2>/dev/null</span></div><div><br></div><div><span>/usr/lib/x86_64-linux-gnu/libtk8.6.so</span></div><div><span>[/code]</span></div><div><br></div><div><span>Check for 'pkgIndex.tcl' (Tk package index):</span></div><div><span>[code]</span></div><div><span>$ find /usr/lib /usr/share -name pkgIndex.tcl 2>/dev/null | grep tk8.6</span></div><div><br></div><div><span>/usr/lib/tcltk/x86_64-linux-gnu/tk8.6/pkgIndex.tcl</span></div><div><span>[/code]</span></div><div><br></div><div><span>- What This Means:</span></div><div><span> - The Tk runtime library ('<a target="_blank" rel="noreferrer nofollow noopener" href="http://libtk8.6.so">libtk8.6.so</a>') is installed in '/usr/lib/x86_64-linux-gnu', which is typical for architecture-specific libraries on 64-bit Linux systems.</span></div><div><span> - Unfortunately, 'tclsh' relies on '$auto_path' to find Tk’s package index ('pkgIndex.tcl'), which should be in '/usr/lib/tcltk/tk8.6' or '/usr/lib/x86_64-linux-gnu/tk8.6'.</span></div><div><span> </span></div><div><span>- Missing 'pkgIndex.tcl':</span></div><div><span> - Tk’s package index ('pkgIndex.tcl') is likely in '/usr/lib/x86_64-linux-gnu/tk8.6' or '/usr/lib/tcltk/tk8.6', but your 'ls' output only showed '<a target="_blank" rel="noreferrer nofollow noopener" href="http://tkConfig.sh">tkConfig.sh</a>' in `/usr/lib/x86_64-linux-gnu/tk8.6', suggesting an incomplete Tk installation or missing directory in '$auto_path'.</span></div><div><br></div><div><span>I think the Debian Package should install '<a target="_blank" rel="noreferrer nofollow noopener" href="http://libtk8.6.so">libtk8.6.so</a>' where 'tk_version' expects to find it, instead of in '/usr/lib/x86_64-linux-gnu'.</span></div><div><br></div><div><span>If the location is not as expected by TCL/TK: </span></div><div><span> Any apps built will not be portable to all systems.</span></div><div><span> Older TCL apps built on 32bit systems may not run as expected on some x86_64 systems using this installation sheme.</span></div><div><span> A novice trialing TCL apps may not be capable of discovering why this app isn't running.</span></div><div><br></div><div><span>I am that novice learning programming. Without AI, I would be lost, unable to find this solution.</span></div><div><br></div><div><br></div><div><br></div><div><br></div><div><span>::Caution in applying this fix:</span></div><div><span>Update '$auto_path':</span></div><div><span>If '<a target="_blank" rel="noreferrer nofollow noopener" href="http://libtk8.6.so">libtk8.6.so</a>' is in '/usr/lib/x86_64-linux-gnu', add it to '$auto_path':</span></div><div><br></div><div><span>[code]</span></div><div><span>$ sudo lappend auto_path /usr/lib/x86_64-linux-gnu</span></div><div><span>[/code]</span></div><div><span>[code]</span></div><div><span>tclsh</span></div><div><span>% puts "Tcl version: $tcl_version"</span></div><div><span>% puts "auto_path: $auto_path"</span></div><div><span>[/code]</span></div><div><br></div><div><span>Expected Output:</span></div><div><span>[code]</span></div><div><span>Tcl version: 8.6</span></div><div><span>auto_path: ... /usr/lib/x86_64-linux-gnu</span></div><div><span>Tk version: 8.6</span></div><div><span>[/code]</span></div><span></span></div><div style="font-family: Arial, sans-serif; font-size: 14px;"><br></div><div style="font-family: Arial, sans-serif; font-size: 14px;">Daniel Ziegler</div><div style="font-family: Arial, sans-serif; font-size: 14px;">daoneiel@proton.me<br></div><div style="font-family: Arial, sans-serif; font-size: 14px;"><br></div>
<div style="font-family: Arial, sans-serif; font-size: 14px;" class="protonmail_signature_block">
<div class="protonmail_signature_block-user protonmail_signature_block-empty">
</div>
<div class="protonmail_signature_block-proton">
Sent with <a href="https://proton.me/mail/home" target="_blank">Proton Mail</a> secure email.
</div>
</div>