Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2024-12-22
22:17
Make a start fixing [209fd9adce]: package files documented behaviour. First remove the wrong behavio... leaf check-in: 9af30a459f user: jan.nijtmans tags: bug-209fd9adce
2024-09-30
11:59 • Ticket [209fd9adce] package files documented behaviour status still Open wit... artifact: 61a9f1b6c8 user: jan.nijtmans
09:20 • Ticket [209fd9adce]: 4 changes artifact: 47107f97dd user: jan.nijtmans
2024-09-29
07:34 • Ticket [209fd9adce]: 3 changes artifact: 85881aa862 user: juliannoble2
07:32 • New ticket [209fd9adce]. artifact: 936aba9125 user: juliannoble2

package files documented behaviour

Open209fd9adce08b582db292b4f1088bb57a8400d49Created 2 years agoUpdated 2 years ago
Descriptionplain2024-09-29 07:32:06
The documentation for 'package files <package>' states:

"Lists all files forming part of package. Auto-loaded files are not included in this list, only files which were directly sourced during package initialization. The list order corresponds with the order in which the files were sourced."

What exactly is meant by Auto-loaded files? Just those put in ::auto_index related to the package - or also those when Tcl has to scan module/library paths?

On a system with no accelerators such as critcl,cryptkit or trf - and also with additional entries in ::auto_path

    #llength [package require md5;package files md5]
    1181

(md5 package attempts to load the non-present accelerators - resulting in scanning the library paths)

It is returning all the pkgIndex.tcl paths from unrelated packages

I found this behaviour somewhat useful to determine when such scans are happening (as the performance impacts can be heavy) but I'd like to know if this is intentional or not - as the files are technically sourced - but the documentation could be read to infer it shouldn't return these.

People testing on one system where 'package files <pkg>' returns a small set of relevant results may be surprised to get huge listings on another system, so if the behaviour as is, is correct - I think the issue should be highlighted in the docs.
Referenced by1
  • 9af30a459fMake a start fixing [209fd9adce]: package files documented behaviour. First remove the wrong behavior, storing "pkgIndex.tcl" filenames at the wrong moment. check-in2024-12-22 22:17:03
juliannoble2plain2024-09-29 07:34:02
I'd also note that when this happens, the documentation statement: "Lists all files forming part of a package" becomes an inaccurate description.
jan.nijtmanswiki2024-09-30 09:20:34

Thanks for the report!

This is - indeed - not intentional. I'll think of a way how to prevent that.

jan.nijtmanswiki2024-09-30 11:59:13

Idea how to solve this: Currently, all "pkgIndex.tcl" files are added to the list at the moment they are sourced. Whenever a "package ifneeded" is executed, we store the name of the file being executed (which is the pkgIndex.tcl file) in the "package ifneeded" data.

Then, when the "package require" command ends and the package is actually sourced, we known the version number, so we can search for the correct pkgIndex.tcl file in the "package ifneeded" data, and add it to the list.

Log in (anonymous is fine) to add a comment.