[Pkg-tcltk-devel] Bug#1119314: TCL fails to find 'libtk8.6.so' in '$auto_path' causing execution to fail

daoneiel daoneiel at proton.me
Wed Oct 29 08:52:58 GMT 2025


Package: tcl
Package: tk

I am having trouble running my TCL app with this structure /project/main.tcl, data.tcl, db.tcl, gui.tcl, file.sqlite.
The app functions fine as a single file. I broke it down into separate files to make maintaining it easier for future growth.

Note: I am learning to program so I am not sure how to diagnose the issue thoroughly.
I have been using Grok to help me understand what happened.
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.
After it didn't appear to be a code structure issue I began to suspect a deeper issue.
Since my error resolution skills are just emerging, I enlisted AI.
I have removed the markdown structure.

The Error begins after main.tcl begins to execute, the error starts with 'source "db.tcl"'.

[code]
/home/user/project-app/
├── main.tcl
├── db.tcl
├── gui.tcl
├── data.tcl
├── file.sqlite
[/code]

Check with:
[code]$ ls -l /home/user/project-app/[/code]
The permissions for all of the .tcl files: -rw-rw-r--
The permissions for one of the files, file.sqlite: -rwxrwxr-x
I don't think this is an issue as 'tclsh' executes these scripts, they just need to be read/write accessible.

Check if '/home' is mounted with 'noexec':
[code]bash
mount | grep /home[/code]
The home partition is not mounted with 'noexec'.

Everything passes until I get to checking tclsh 'Environement'. This is where it fails:

[code]
% tclsh -c "puts $tcl_version; package require Tk; puts $tk_version"
can't read "tk_version": no such variable
[/code]

The 'package require Tk' command failed silently (e.g., Tk is not installed or not found), so 'tk_version' was never set.

- Environment Variables:
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.

- Incomplete Output:
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.

Running each command individually to verify the issue:
[code]
$ wish
% puts $tcl_version
8.6
% puts $tk_version
8.6

$ tclsh
% puts $tcl_version
8.6
% puts $tk_version
can't read "tk_version": no such variable

% puts $auto_path
/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
[/code]

- 'puts $auto_path' lists directories where Tcl looks for packages (e.g., `/usr/lib/tcl8.6`, `/usr/lib/tk8.6`).
With Tk is missing, I checked for Tk libraries:

[code]
ls /usr/lib/tcltk/* /usr/lib/*tcl* /usr/local/lib/*tcl*

ls: cannot access '/usr/local/lib/*tcl*': No such file or directory
/usr/lib/tclConfig.sh /usr/lib/tclooConfig.sh

/usr/lib/tcl8.6:
tclConfig.sh tclooConfig.sh

/usr/lib/tcltk:
sqlite3 TclCurl7.22.1 x86_64-linux-gnu

/usr/lib/tcltk/sqlite3:
libtclsqlite3.la libtclsqlite3.so pkgIndex.tcl

/usr/lib/tcltk/TclCurl7.22.1:
libTclCurl7.22.1.so pkgIndex.tcl tclcurl.tcl

/usr/lib/tcltk/x86_64-linux-gnu:
tclreadline2.4.0 tclxml3.2 thread2.8.11 tk8.6 tls1.8.0 udp1.0.12
[/code]

If 'package require Tk' fails, (It doesn't) I check Tk installation anyway:
[code]
dpkg -l | grep tk
[/code]

Everything looks good with installation list.
- 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.

Step 1: Analyzing the `$auto_path` Output
The `$auto_path` output you provided is:
```
/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
```
- What This Means:
- '$auto_path' lists directories where Tcl searches for packages (e.g., Tk) when 'package require' is called.
- Key directories include:
- '/usr/share/tcltk/tcl8.6': Tcl 8.6 libraries.
- '/usr/lib/tcltk/x86_64-linux-gnu': Architecture-specific Tcl/Tk libraries.
- '/usr/lib/tcltk/tcl8.6': Tcl 8.6-specific libraries.
- '/usr/share/tcltk': General Tcl/Tk shared files.
- '/usr/share/tcltk/ttkthemes': Tk themes (for `ttk` widgets, used in your app’s search bar).
- 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.

- Implications:
- 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.

Step 2: Why the '$tk_version' Error Occurred:
The error 'can't read "tk_version": no such variable` occurs because:
1. Tk Package Not Loaded:
- 'package require Tk' in 'tclsh' fails to load Tk, likely because the Tk package ('pkgIndex.tcl' and 'libtk8.6.so') is not in '$auto_path' or not installed.
- Without Tk loaded, 'tk_version' is not defined, causing the error.

Check Tk library files:
[code]
$ ls /usr/lib/tcltk/tk* /usr/lib/*/tk* /usr/share/tcltk/tk*

ls: cannot access '/usr/lib/tcltk/tk*': No such file or directory
/usr/lib/tk8.6/tkConfig.sh /usr/lib/x86_64-linux-gnu/tkConfig.sh

/usr/lib/x86_64-linux-gnu/tk8.6:
tkConfig.sh

/usr/share/tcltk/tk8.6:
bgerror.tcl comdlg.tcl focus.tcl images mkpsenc.tcl optMenu.tcl scale.tcl tearoff.tcl tk.tcl
button.tcl console.tcl fontchooser.tcl listbox.tcl msgbox.tcl palette.tcl scrlbar.tcl text.tcl ttk
choosedir.tcl dialog.tcl iconlist.tcl megawidget.tcl msgs panedwindow.tcl spinbox.tcl tkAppInit.c unsupported.tcl
clrpick.tcl entry.tcl icons.tcl menu.tcl obsolete.tcl safetk.tcl tclIndex tkfbox.tcl xmfbox.tcl
[/code]
Expect to see '/usr/lib/tcltk/tk8.6' or similar, containing 'pkgIndex.tcl' and 'libtk8.6.so'.

Check Tk Path:
[code]
$ find /usr/lib /usr/share -name "tk8.6" 2>/dev/null

/usr/lib/x86_64-linux-gnu/tk8.6
/usr/lib/tk8.6
/usr/lib/tcltk/x86_64-linux-gnu/tk8.6
/usr/share/doc/tk8.6
/usr/share/tcltk/tk8.6
[/code]

- Key Observations:
- 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).
- '/usr/lib/tk8.6/tkConfig.sh': Contains Tk build configuration, not the runtime library ('libtk8.6.so') or package index ('pkgIndex.tcl').
- '/usr/lib/x86_64-linux-gnu/tk8.6/tkConfig.sh': Another Tk configuration file, likely for architecture-specific builds.
- '/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 ('libtk8.6.so') is missing from this output.
- Missing 'libtk8.6.so': 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'.

- '$auto_path' (from previous response):
Includes '/usr/share/tcltk/tk8.6' (where Tk scripts are) but not '/usr/lib/x86_64-linux-gnu' (where 'libtk8.6.so' likely resides).
- Implications:
- The Tk package is partially installed: Tcl scripts are in '/usr/share/tcltk/tk8.6', but the runtime library ('libtk8.6.so') is missing or not in '$auto_path'.
- 'tclsh' fails to load Tk ('package require Tk') because it can’t find 'libtk8.6.so' or 'pkgIndex.tcl' for Tk 8.6.

Missing Library:
- The 'ls' output doesn’t show 'libtk8.6.so', 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.

Locate 'libtk8.6.so'
Check for the Tk library:
[code]
$ find /usr/lib /usr/share -name libtk8.6.so 2>/dev/null

/usr/lib/x86_64-linux-gnu/libtk8.6.so
[/code]

Check for 'pkgIndex.tcl' (Tk package index):
[code]
$ find /usr/lib /usr/share -name pkgIndex.tcl 2>/dev/null | grep tk8.6

/usr/lib/tcltk/x86_64-linux-gnu/tk8.6/pkgIndex.tcl
[/code]

- What This Means:
- The Tk runtime library ('libtk8.6.so') is installed in '/usr/lib/x86_64-linux-gnu', which is typical for architecture-specific libraries on 64-bit Linux systems.
- 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'.

- Missing 'pkgIndex.tcl':
- 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 'tkConfig.sh' in `/usr/lib/x86_64-linux-gnu/tk8.6', suggesting an incomplete Tk installation or missing directory in '$auto_path'.

I think the Debian Package should install 'libtk8.6.so' where 'tk_version' expects to find it, instead of in '/usr/lib/x86_64-linux-gnu'.

If the location is not as expected by TCL/TK:
Any apps built will not be portable to all systems.
Older TCL apps built on 32bit systems may not run as expected on some x86_64 systems using this installation sheme.
A novice trialing TCL apps may not be capable of discovering why this app isn't running.

I am that novice learning programming. Without AI, I would be lost, unable to find this solution.

::Caution in applying this fix:
Update '$auto_path':
If 'libtk8.6.so' is in '/usr/lib/x86_64-linux-gnu', add it to '$auto_path':

[code]
$ sudo lappend auto_path /usr/lib/x86_64-linux-gnu
[/code]
[code]
tclsh
% puts "Tcl version: $tcl_version"
% puts "auto_path: $auto_path"
[/code]

Expected Output:
[code]
Tcl version: 8.6
auto_path: ... /usr/lib/x86_64-linux-gnu
Tk version: 8.6
[/code]

Daniel Ziegler
daoneiel at proton.me

Sent with [Proton Mail](https://proton.me/mail/home) secure email.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-tcltk-devel/attachments/20251029/71163c7e/attachment-0001.htm>


More information about the Pkg-tcltk-devel mailing list