Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 6d60de932fe5a59706d014f9cd39c723f7f9e8a6096523e0b3c12a0303292fce
Ticket: a998df01f3256f79f4d7d635517130012b4001f5
Attempt to load platform package in a pkgIndex.tcl generates circular dependency error
User & Date: jan.nijtmans on 2022-07-05 06:20:39
Changes

  1. icomment:
    In stead of this:
    
    <pre>
        package require platform
        package ifneeded testpkg 0.1 [list load [file join $dir [platform::identify] mybinaryextension.[info sharedlibextension]]
    </pre>
    
    You should do:
    
    <pre>
        package require platform
        package ifneeded testpkg 0.1 "package require platform \
        [list load [file join $dir [platform::identify] mybinaryextension.[info sharedlibextension]]"
    </pre>
    
    Then the "package require platform" is executed when testpkg is required.
    
    The problem with your approach is that the following could happen:
    
    <pre>
    $ tclsh8.7
    $ package files platform; # empty result, since "platform" is not loaded yet
    $ package require Thread
    % package files platform; # "platform" is - unexpectedly - loaded now
    /usr/local/lib/tcl8/8.4/platform-1.0.18.tm
    </pre>
    (whether this happens or not depends on the order the "pkgIndex.tcl" files are found)
    
    
    So, a "package require Thread" results in pkgIndex.tcl files being sourced (in order to see where "Thread" is. This has a side-effect that the "platform" package is loaded, but it is not needed by "Thread" at all.
    
    It should be documented that a "pkgIndex.tcl" file should not contain another "package require" nor "package load", unless it's within a "package ifneeded".
    
  2. login: "jan.nijtmans"
  3. mimetype: "text/x-markdown"
  4. resolution changed to: "Invalid"
  5. status changed to: "Pending"