Menu

#52 Can't find a usable tclx.tcl

open
nobody
None
9
2014-08-25
2008-03-05
relaxmike
No

While trying to include Tclx in a Starpack,
I was surprised to find that the loading
mechanism is not behaving correctly.

The following simple script reproduces the bug :

package require Tcl
package require Tk
lappend ::auto_path [file join [file dirname [info script]] "TclxMod"]
package require Tclx

I made a local copy of the Tclx package into the
local directory TclxMod, located just in the same directory that the current script is.
The "lappend ::auto_path" makes the package Tclx available to the "package require" system.

But I got the following message while trying to execute the script :

********************************

Can't find a usable tclx.tcl in the following directories:
C:/ActiveTcl8.4.16/lib/tcl8.4/tclx8.4 C:/ActiveTcl8.4.16/lib/tclx8.4 {d:/documents and settings/bandinm/teapot/repository/package/win32-ix86/lib/tclx8.4} {d:/documents and settings/bandinm/teapot/repository/package/tcl/lib/tclx8.4} C:/ActiveTcl8.4.16/lib/tcllib1.10/tclx8.4 C:/ActiveTcl8.4.16/lib/tklib0.4/tclx8.4 C:/ActiveTcl8.4.16/lib/tk8.4/tclx8.4 ./TclxMod/tclx8.4 C:/lib/tclx8.4 C:/ActiveTcl8.4.16/library C:/library C:/tclx8.4.0/library

This probably means that tclx wasn't installed properly.

while executing
"error $msg"
(procedure "tcl_findLibrary" line 116)
invoked from within
"tcl_findLibrary tclx 8.4 8.4.0 tclx.tcl TCLX_LIBRARY tclx_library"
(procedure "::tclx::Init" line 3)
invoked from within
"::tclx::Init"
(in TclX_Init)
invoked from within
"load C:/ActiveTcl8.4.16/lib/tclx8.4qslmkjqsdf/tclx84.dll Tclx"
("package ifneeded" script)
invoked from within
"package require Tclx"
(file "main.tclx.tcl" line 4)
********************************

It appears that the Tclx loading system searches
for a subdirectory called "tclx8.4" in all the
directories found in the auto_path variable.
This is not what I expected, since the "package require" system provides the local variable "dir", which is used in the pkgIndex.tcl file :

package ifneeded Tclx 8.4 [list load [file join $dir tclx84.dll] Tclx]

If so, that path should be considered first in the binary so that the package can be found where the .dll is located, isn't it ?

The workaround is to rename the local copy from TclxMod to tclx8.4 and to modify the script, so that the local directory is a part of the auto_path :

lappend ::auto_path [file join [file dirname [info script]]]

Here, Tclx finds the subdirectory "tclx8.4" in the local directory and it works.

I think that there may be a bug here, so I submit it.

Best regards,

Michaël

PS
The link to the StarPack is that when using the TDK's TclApp software, TclApp renames the directories associated which each package. For example, the directory containing the Tclx package is renamed to :

lib/P-win32-ix86-Tclx-8.4

This works fine for all packages, except for Tclx, because of the previous bug.

Discussion

  • relaxmike

    relaxmike - 2008-03-05
    • priority: 5 --> 7
     
  • relaxmike

    relaxmike - 2008-03-05
    • priority: 7 --> 9
     
  • relaxmike

    relaxmike - 2008-03-05

    Logged In: YES
    user_id=1573661
    Originator: YES

    Just to ease the debugging process, this was the answer of Andreas, after
    a discussion on the Active State TDK support forum.
    Best regards,
    Michaël

    TclX:

    That is ... bad. IIRC Tclx uses the tcl_findLibrary command to locate its init.tcl file from within the shared library ... That command could very well have this limitation that it needs the Tclx8.4 directory :(

    A workaround would be to add

    set env(TCLX_LIBRARY) [file join [file dirname [info script]] lib P-macosx-universal-Tclx-8.4]

    to the initialization code (See panel 'Advanced').

    The proper fix would be to modify Tclx to not use tcl_findLibrary any more, but explicitly source its init.tcl file from its 'package ifneeded' script.

     

Log in to post a comment.