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.
proc tclLog {msg} {puts "LOG: $msg"}
before doing the firstpackage require
? – Donal Fellowsinfo patchlevel
to find out. – Donal Fellows