tclpdf

Why 1.6.1 — the same number, a different file
Login

Why 1.6.1 — the same number, a different file

tclpdf 1.6.1 follows 1.6 by one day and adds no feature. It corrects a release defect: 1.6 shipped modules whose content had changed while they still announced the module version of an earlier release. With one release installed nothing shows. With two side by side, the newer main package ran on older modules. This note says what happened, why no check saw it, what 1.6.1 changes, and how to ask an installation which files it actually loads.

What happened

A module version is a promise about the file: two copies that announce the same number are interchangeable, and Tcl relies on that and on nothing else. 1.6 broke the promise for three modules against 1.5 — io 1.2, text 1.25 and textBlock 1.19 had all changed, for the table cells of runs and for the rework of io, and kept the numbers they carried in 1.5. The check written afterwards went through every release tag and found two older cases of the same kind: sign 1.7 changed after 1.3 and structureDest 1.1 after 1.2, both under the number of the earlier release. Five modules in all, measured against the tags; no other module of 1.6 matches the version of an earlier release with different content.

How it showed

On a user's machine lib/tclpdf1.5 and lib/tclpdf1.6 stood next to each other — the normal state after make install of a new version. Both pkgIndex.tcl files register tclpdf::textBlock 1.19, and the same holds for text 1.25 and io 1.2. When two scripts are registered for the same version, Tcl runs the one registered last, and which one that is depends on the order in which the index files are read, not on anything the package decides. Here package require tclpdf answered 1.6 and loaded textBlock, text and io from the 1.5 directory. Everything 1.5 could do kept working. The first thing that needed the new code — a table cell set from runs, new in 1.6 — died inside the layout:

unknown method "TextLinesWidest": must be <cloned>, BytesStr, CheckDate, ...

The error code is TCL LOOKUP METHOD TextLinesWidest; the message goes on to list every method of the document object. Rebuilt from the two release tags side by side in a scratch directory, the failure is the same under Tcl 8.6 and Tcl 9.0.

Why no check saw it

In the source tree exactly one directory is on the path: the test suite and every example put the tree in front, so there is never a second copy to lose against. tests/version.test compared the number in each module with the number in pkgIndex.tcl — consistency within one release, and nothing about the release before. Raising a module version was a manual step without a guard, and a manual step without a guard is forgotten sooner or later. Here it was forgotten twice: when the table cells touched text and textBlock, and when io was rebuilt.

What 1.6.1 changes

Nine module versions, five because the module changed since a release that carried its number, four because the module now requires one of those:

Module 1.6 1.6.1 Reason
io 1.2 1.3 changed since 1.5
text 1.25 1.26 changed since 1.5
textBlock 1.19 1.20 changed since 1.5
sign 1.7 1.8 changed since 1.3
structureDest 1.1 1.2 changed since 1.2
tableLayout 1.8 1.9 requires textBlock 1.20
tableDraw 1.7 1.8 requires text 1.26
table 1.11 1.12 requires tableLayout 1.8
timestamp 1.0 1.1 requires sign 1.8

Each module now requires the version of the module whose new code it calls, where it used to accept any 1.x: tableLayout asks for textBlock 1.20- for TextLinesWidest, tableDraw for text 1.26- for one broken line of runs, text for textBlock 1.20-. Tcl then picks the newer file among the installed ones, and where only the older exists, a mixed installation fails at package require instead of halfway through drawing a table.

The guard is tests/release.test, new in 1.6.1. Its first test holds that the same module version means the same content: for every version-* tag in the repository, a module whose number equals the one in that tag has to be the tag's file byte for byte. Its second group installs the youngest release before the tree and the tree itself side by side, in both orders on auto_path, and requires that every loaded module is the tree's file and that a table cell of runs can be set. Before the fix the first test was red and named exactly the five modules above; against 1.6.1 all three tests pass. It needs fossil and a checkout and skips itself otherwise, so it does not run from an unpacked source archive.

Beyond the version numbers, the narrowed requirements and the new test, 1.6.1 changes nothing in the package against 1.6. The state of the release: 4660 tests under Tcl 8.6 and Tcl 9.0, and make check with 91 checks passed.

What to do

Whoever installed 1.6 beside 1.5 or an older release takes 1.6.1. For any installation, this asks Tcl where a module came from; the text call is there because textBlock is loaded on first use, and package present fails before that:

package require tclpdf
set doc [tclpdf new]
$doc page add
$doc text "probe" -at {20 30} -width 80
puts [package ifneeded tclpdf::textBlock [package present tclpdf::textBlock]]

The answer is the source command with the full path of the file that was loaded. If its directory is not the one of the release package require tclpdf reported, the installation is mixed. The same question works for any other module, tclpdf::text or tclpdf::io among them.