0
votes

I have two Tcl 8.4 installations on Windows. Here is the one which looks good:

(Inside tclsh):

% set auto_path
c:/Tcl/lib/tcl8.4 c:/Tcl/lib
% package require csv
0.8

The package csv is located here:

dir c:\Tcl\lib\tcllib1.15\csv
    06.06.2013  07:52            20.154 csv.tcl
    06.06.2013  07:52               126 pkgIndex.tcl

Here is the other one, which can't locate the csv package:

% set auto_path
C:/cygwin64/home/fisrona/gitwrk/vp/lib/tcl8.4 C:/cygwin64/home/fisrona/gitwrk/vp/lib
% package require csv
can't find package csv 

In this installation, the package is located here:

dir C:\cygwin64\home\fisrona\gitwrk\vp\lib\tcllib1.15\csv
    03.02.2015  08:59            20.154 csv.tcl
    03.02.2015  08:59               126 pkgIndex.tcl

In both cases, the auto_path contains the lib directory, and the package is located at tcllib1.15/csv below the lib directory. The pkgIndex.tcl is identical in both cases and looks like this:

if {![package vsatisfies [package provide Tcl] 8.4]} {return}
package ifneeded csv 0.8 [list source [file join $dir csv.tcl]]

There must be something different between the two installations, which causes the second one to fail. Any idea what could be the reason?

BTW, the init.tcl (located in both cases in lib/tcl8.4) in both installations is identical too. Of course, if I add the tcllib1.15 directory explicitly to auto_path, the package is found; but why is the package found in the first case, where I did NOT have to add this directory, but not in the second case?

==========

NEW FINDING:

In the good installation, when I do a require of a non-existing package, and then display auto_path again, I get the following result:

% set auto_path
c:/Tcl/lib/tcl8.4 c:/Tcl/lib
% package require xxx
can't find package xxx
% set auto_path
c:/Tcl/lib/tcl8.4 c:/Tcl/lib c:/Tcl/lib/tcllib1.15 c:/Tcl/lib/tcllib1.7 c:/Tcl/lib/tklib0.6 c:/Tcl/lib/vfs1.4.2/template

It looks like a handler kicks in, when an unknown package is required, and this handler extends the auto_path. In particular, the directory tcllib1.15 is added, which contains the csv directory. If I do the same in the "bad" installation, I see this:

% package require xxx
can't find package xxx
% set auto_path
C:/cygwin64/home/fisrona/gitwrk/vp/lib/tcl8.4 C:/cygwin64/home/fisrona/gitwrk/vp/lib C:/cygwin64/home/fisrona/gitwrk/vp/lib/tcllib1.7

In this case, only one directory has been added, and this is not the one containing the csv file.

The difference seems to be the way that the "unknown package handling" is extending the auto_path. I just wonder, where I can find this handler? I found in init.tcl the following command:

package unknown [list ::tcl::tm::UnknownHandler [package unknown]]

I found this handler in lib/tcl8.4/tm.tcl . These files are also identical in both versions.

Looks like I have to step manually through the execution of UnknownHandler to find out what's going on.... I will report my findings here.

1
What happens if you do proc tclLog {msg} {puts "LOG: $msg"} before doing the first package require?Donal Fellows
Also… what exact patchlevel of Tcl is this? Use info patchlevel to find out.Donal Fellows
Defining tclLog has no effect, i.e. I don't get any log messages. The patch level is 8.4.20 in both cases (the non-working Tcl installation was created by simply copying the working one).user1934428
BTW, I have new findings about the problem, and have added them to the question. Maybe you could have a look.....user1934428
Solved it! Thanks a lot for trying to help!!!user1934428

1 Answers

0
votes

Solved!!!!! Ah, what a silly mistake:

While in both installations, the csv directory had a pkgIndex.tcl file, this file was missing in the broken installation from the tcllib1.15 directory.

Upon the package require csv, the handler ::tcl::tm::UnknownHandler was invoked, which could not resolve it, but then the standard handler (returned by [package unknown] kicked in. This is a procedure tclPkgUnknown, defined in my installation in tcl8.4/package.tcl. This procedure searches all entries in the directories found in auto_path. If one of these directories has a subdirectory, and a pkgIndex.tcl file is found there as well, the entries in that file are also considered (and this directory is added to the auto_path).

Solution: I have to provide a suitable pkgIndex.tcl for my directory tcllib1.15 too.