Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: b815a1e33e99451c399154e17a0e8cb608784e26d16e2bd3dccc2a93dbf39a99
Ticket: a998df01f3256f79f4d7d635517130012b4001f5
Attempt to load platform package in a pkgIndex.tcl generates circular dependency error
User & Date: jan.nijtmans on 2022-07-04 19:09:05
Changes

  1. assignee changed to: "jan.nijtmans"
  2. icomment:
    Well - first - if 'testpkg' needs 'platform', `the correct` way to do this is as follows:
    <pre>
    ########## pkgIndex.tcl ########
    package ifneeded testpkg 0.1 [list source [file join $dir testpkg.tcl]]
    
    ########## testpkg.tcl ########
    package require platform; # <-- should be here, not in pkgIndex.tcl
    proc testproc {} {puts "testpkg loaded"}
    package provide testpkg 0.1
    </pre>
    
    The pkgIndex system is complex. If a package is not found when doing a "package require", more file paths are searched for a 'pkgIndex' file. Therefore, a 'pkgIndex' file should only contain commands which have no side-effects, it should NEVER do another 'package require' directly or a 'load'. 'pkgIndex' files should hardly do anything more than 'package ifneeded'.
    
    The reason Tcl 8.7 discovers this and 8.6 doesn't is [https://core.tcl-lang.org/tips/doc/trunk/tip/459.md|TIP #459]. Tcl 8.7 keeps track, which files are sourced in which package initialization, so 'package files' can report it. Maybe the error-message could be better .....
    
    Does this explanation make it a little bit more clear?
    
  3. login: "jan.nijtmans"
  4. mimetype: "text/x-fossil-wiki"
  5. resolution changed to: "Invalid"
  6. status changed to: "Pending"