Tcl Library Source Code

Ticket Change Details
Login
Overview

Artifact ID: cc38258b39b5f29916e44c1224ea73f701f960dc253a6bf3f9c0b0c664ade4b9
Ticket: e5f3dfc055cfd4cbd2928ff964413749f321c88e
tcllib 2.0 install fails with default Tcl build
User & Date: marc_culler 2025-06-09 02:10:33
Changes

  1. assignee changed to: ""
  2. icomment:
    As mentioned on the Core list, the default path is also wrong on macOS.
    However, on macOS the script uses ::tcl_pkgPath, but that has the same
    value as auto_path on macOS and does not exist on Windows.
    
    The script would work correctly on macOS if it used the first path on the
    auto_path list, instead of the last.  On Windows the correct path is the
    last one on the auto_path list, but the script does not use auto_path at
    all.
    
    The actual code is:
    
            if {[string match [info nameofexecutable]* [info library]]} {
                # Starkit
                set libdir [file join [file dirname [file dirname [info nameofexecutable]]] lib]
            } else {
                # Unwrapped.
                if {[catch {set libdir [lindex $::tcl_pkgPath end]}]} {
                    set libdir [file dirname [info library]]
                }
            }
    
    The catch statement succeeds on macOS, giving the wrong answer, and fails
    on Windows causing the result of [info library] to be used.  On Windows
    [info library] returns //zipfs:/lib/tcl/tcl_library.
    
    The default values of auto_path on linux, windows and macOS (with a
    framewor build) are as follows (where $PREFIX is the prefix on unix
    and the value of INSTALLDIR on Windows)
    
    linux: //zipfs:/lib/tcl/tcl_library //zipfs:/lib/tcl $PREFIX/lib
    
    Windows: //zipfs:/lib/tcl/tcl_library //zipfs:/lib/tcl $PREFIX/lib
    
    macOS: /Library/Frameworks/Tcl.framework/Versions/9.1/Resources/Scripts
     /Library/Frameworks/Tcl.framework/Versions/9.1/Resources /usr/local/lib
     $HOME/Library/Tcl /Library/Tcl $HOME/Library/Frameworks
     /Library/Frameworks /Library/Frameworks/Tk.framework/Versions
    
    For macOS many of those paths would never contain a package, and are
    unlikely to even exist.  But that is more of a Tcl issue than a
    Tcllib issue.
    
    I think that one solution (given the current state of things) would
    be to use the first item in the auto_path which does not begin with
    "//zipfs:" as the default installation path.  That is guaranteed to
    be a place where Tcl will look, and it is likely to also be a writable
    directory, at least in the case where one is running the installer as
    root on a unix system.
    
  3. login: "marc_culler"
  4. mimetype: "text/plain"
  5. username: "Marc Culler"