Tcl Source Code

View Ticket
Login
Ticket UUID: 85bbfda852459a18912bcd1c131b71d0210b975d
Title: Should [package prefer stable] prompt repeated searches?
Type: Bug Created on: 2017-11-14 17:44:11
Submitter: dgp Assigned to: aku
Subsystem: 39. Package Manager Severity: Minor
Priority: 5 Medium Last modified: 2017-11-17 19:59:42
Status: Open Closed by: nobody
Resolution: None Closed on:
Version: 8.5+
Description:
% package prefer
stable
% proc find {args} {
    package ifneeded p 1.0 {package provide p 1.0}
}
% package unknown find
% package ifneeded p 1.1a0 {package provide p 1.1a0}
% package require p 1.0
1.1a0
User Comments:
dgp added on 2017-11-14 17:53:01:
The primary purpose of [package require] is to
bring in a version of the requested package that
satisfies the stated requirements.  In the demo
commands above, that primary purpose is fulfilled.
Version 1.1a0 satisfies a request for 1.0.

Secondary purposes are to honor the [package prefer]
setting, and to select later over older versions
that all satisfy the requirement.  The documentation
has always been vague about when you can expect the
secondary purposes to be satisfied.  In the demo
commands, we fail the secondary purposes. We make use
of an alpha version even though the total system makes
a suitable stable version available.

The dilemma is that the only way to always guarantee
the secondary purposes will be satisfied is to promise
every [package require] call will take a trip through
a call to the current [package unknown] handler -- just
to be sure there's not something better.  And typical
handler calls are expensive.

In practice, we have not guaranteed the latest version
available for just this reason, and I think we're slowly
getting better about making that known.

The open question here is whether a "stable" preference
is different enough that it should trigger a different
judgment. My initial reaction is that it isn't, and this
isn't really a bug, but let's see how others react.

aku added on 2017-11-17 19:59:42:
Huh. Yes. The difference between packages on disk, and the package database in memory. And 'package require' only going to disk if the package is not known in memory yet.

An argument could be made that libtcl should go to the disk only once, on first `require` and then consider what it has in memory as fixed, i.e. nothing on the disk will change during operation.

What messes this up (now) is the existence of Tcl Modules. While we introduced them to make search/startup faster (by doing a more targeted/limited search), their existence now means that a single scan will definitely not find all installed packages, as it would have before their introduction.

I suspect we need a big discussion of many aspects of package handling before Tcl 9 becomes final. Because that is opportunity to straighten out the kinks we put into the system. And Tcl Modules, while nice, are a kink, a band-aid.