Tcl Source Code

View Ticket
Login
Ticket UUID: 1655677
Title: tcl_findLibrary is not thorough enough
Type: RFE Version: None
Submitter: wart Created on: 2007-02-09 01:38:45
Subsystem: 38. Init - Library - Autoload Assigned To: dgp
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2007-02-09 22:46:15
Resolution: Invalid Closed By: dgp
    Closed on: 2007-02-09 15:46:15
Description:
Let me preface by stating that this only causes problems when running Tcl with a slightly stripped-down auto_path.  I realize this is a non-standard configuration, but hope that the solution makes sense in the general case as well.

The tcl_findLibrary procedure is used to locate a packages foo.tcl script by looking in a few common locations.  Unfortunately, it does not look in the sibling directory of Tcl's own script library.  This causes problems for Tk when Tcl is built with a restricted auto_path.

One directory that is not used in this search is the sibling of [::tcl::pkgconfig get scriptdir,runtime]:

set value [::tcl::pkgconfig get scriptdir,runtime]
[file join [file dirname $value] $basename$version]

For example, if Tcl's script library is installed in /usr/share/tcl8.5, then tcl_findLibrary should look for foo's script library in /usr/share/foo8.5.

This is not an issue in the standard Tcl/Tk installation because tcl_findLibrary also searches in subdirectories of auto_path, which includes the massive /usr/lib and /usr/share directories.  But if Tcl is used with a restricted auto_path containing only /usr/share/tcl8.5 and /usr/lib/tcl8.5, then it won't find tk's tk.tcl in /usr/share/tk8.5.

Also note that the following comment in $tk_src_dir/generic/tkInitScript.h is incorrect, $tcl_library/../tk$tk_version is _not_ a directory that is searched:

" * In order to find tk.tcl during initialization, the following script is
 * invoked by Tk_Init(). It looks in several different directories:
 *
 *      $tk_library             - can specify a primary location, if set no
 *                                other locations will be checked
 *
 *      $env(TK_LIBRARY)        - highest priority so user can always override
 *                                the search path unless the application has
 *                                specified an exact directory above
 *
 *      $tcl_library/../tk$tk_version
 *                              - look relative to init.tcl in an installed
 *                                lib directory (e.g. /usr/local)
"
User Comments: dgp added on 2007-02-09 22:46:15:
Logged In: YES 
user_id=80530
Originator: NO


The bug here is in Tk, and
the solution is the same
solution that will fix
Tk Bug 765642.

[tcl_findLibrary] searches in

  [::${basename}::pkgconfig get scriptdir,runtime]

so all Tk needs to do is use the provided
Tcl_RegisterConfig() routine to record where
its script library has been installed, and
this problem will be corrected.

re-open this issue in the Tk Bug Tracker
and give it a high prio.  The issue with
the out of date comment needs resolving
there as well.

dkf added on 2007-02-09 16:05:07:

data_type - 360894

wart added on 2007-02-09 08:38:45:

File Added - 215155: tcl-8.5a5-findlibrary.patch

Attachments: