Tcl Source Code

View Ticket
Login
Ticket UUID: 006bef5d75f6fd6b12cdbb774cfa1faef94c7835
Title: Tcl cannot run from an arbitrary build directory with --disable-zipfs
Type: Bug Created on: 2026-05-20 13:45:32
Submitter: apnadkarni Assigned to: nobody
Subsystem: 53. Configuration and Build Tools Severity: Important
Priority: 5 Medium Last modified: 2026-05-21 10:08:15
Status: Closed Closed by: apnadkarni
Resolution: Fixed Closed on: 2026-05-21 10:08:15
Version: 9.0
Description:

(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?

User Comments:
apnadkarni added on 2026-05-21 01:17:46:
Proposed fix now in the [bug-006bef5d] branch.

apnadkarni added on 2026-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).