Recently I found that if package require is evaluated with not existing package name and one of pkgIndex files in auto_path again contains package require with not existing package then tclPkgUnknown enters infinite recursion. I wonder is it not allowed to eval package require from pkgIndex or this is a hidden bug?
0
votes
1 Answers
1
votes
A pkgIndex.tcl file should never run package require itself. It should just call package ifneeded to tell the package management system how to load a particular version of a particular package. This is because the index scripts are loaded at times that are rather different — during package discovery — and not necessarily at the point when that version of the package is really wanted. If you stick to this rule, you won't have any problems.
Here's the sort of thing that ought to be in there.
# Maybe some comments here?
package ifneeded Foo 1.2.3 [list source [file join $dir foo.1-2-3.tcl]]
The $dir? That's just the name of the directory containing the index file, for convenience sake. (It's actually a local variable too; the index files are evaluated inside a procedure context.)
package requirein a pkgIndex file? This is just a misuse of the pkgIndex file, not a bug. - Brad Lanam