Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2026-05-21
10:08 • Closed ticket [006bef5d75]: Tcl cannot run from an arbitrary build directory wit... artifact: b39b9ff999 user: apnadkarni
08:30
Fix [006bef5d75] - Tcl cannot run from an arbitrary build directory with --disable-zipfs check-in: 3805cdd634 user: apnadkarni tags: trunk, main
08:25 • Ticket [006bef5d75] Tcl cannot run from an arbitrary build directory with --disa... artifact: 81b83a1838 user: apnadkarni
01:19 • Ticket [006bef5d75]: 3 changes artifact: ed287c942c user: apnadkarni
01:17 • Ticket [006bef5d75]: 3 changes artifact: f8fc68d0c9 user: apnadkarni
2026-05-20
17:03
Proposed fix for [006bef5d75] on Unix. MingW and nmake pending. check-in: 67ce010703 user: apnadkarni tags: bug-006bef5d
13:45 • New ticket [006bef5d75] Tcl cannot run from an arbitrary build directory with --... artifact: 70cf7adf51 user: apnadkarni

Tcl cannot run from an arbitrary build directory with --disable-zipfs

Closed / Fixed006bef5d75f6fd6b12cdbb774cfa1faef94c7835Created 196 days agoUpdated 196 days ago
Descriptionmarkdown2026-05-20 13:45:32

(Below is with reference to the autoconf build system. The nmake build also has the same issue with OPTS=noembed.)

If Tcl is built at an arbitrary location, say in /tmp/90 and configured as

/mnt/c/src/tcltk/wip/tcl/unix/configure --prefix=/tmp/90install --disable-zipfs

an attempt to run it as follows fails.

apnadkarni@IO:/tmp/90$ LD_LIBRARY_PATH=`pwd` ./tclsh
application-specific initialization failed: Cannot find a usable init.tcl in the following directories:
    /tmp/90install/lib/tcl9.0 /tmp/lib/tcl9.0 /lib/tcl9.0 /tmp/library /library /tcl9.0/library /tcl9.0.4/library /tcl9.0.4/library

This probably means that Tcl wasn't installed properly.

Note make test|shell succeed because they set TCL_LIBRARY to the library directory in the sources.

I strongly suspect this is not new to 9.0 but now has assumed more importance for two reasons.

  • While the above would still fail prior to TIP 732, builds within the first level below the configure.ac directory would still work because of Tcl would go searching in multiple places hunting for init.tcl. TIP 732 restricts this. In any case, restoring the earlier searches does not fix the above problem.

  • Being able to run tclsh from the build directory has become more important due to the recent changes in support of a BI installer for packaging purposes when building extensions (including Tk). Admittedly, a selfish interest.

I propose to fix this by introducing additional keys to the tcl::pkgconfig command. The command already includes keys scriptdir,install, scriptdir,runtime, bindir,runtime etc. I would like to add the key scriptdir,build which would hold the script directory path as of build time. The search for init.tcl would then include this path (it already includes the previous two).

The keys returned by tcl::pkgconfig are not documented so I don't think adding new key(s) needs a TIP but happy to write one if folks are happy to vote!

Any comments or alternative solutions?

Referenced by2
  • 3805cdd634Fix [006bef5d75] - Tcl cannot run from an arbitrary build directory with --disable-zipfs check-in2026-05-21 08:30:37
  • 67ce010703Proposed fix for [006bef5d75] on Unix. MingW and nmake pending. check-in2026-05-20 17:03:36
apnadkarniplain2026-05-21 01:17:46
Proposed fix now in the [bug-006bef5d] branch.
apnadkarni Ticket [006bef5d75]: 3 changes [History diff]2026-05-21 01:19:00
apnadkarnimarkdown2026-05-21 08:25:05

Here is final fix: When running from the build directory, and only when running from the build directory tclsh will look in the source library directory for init.tcl. When running after installation, it should not and will not look there.

The original use case arises from using the buildtree (uninstalled) tclsh when building extensions (including Tk). The above solves this without affecting installed tclsh'es which should not be looking into build trees.

The change to pkgconfig is not necessary and not implemented.

Above is for 9.1. No plans to back port to 9.0 which uses a very different initialization implementation (pre-TIP 732).

apnadkarni Closed ticket [006bef5d75]. [History diff]2026-05-21 10:08:15
Log in (anonymous is fine) to add a comment.