Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: fb88ae8699262425b1fbd9117aa99ae238b4d8f0f6d1d51658ed3654312a89d5
Ticket: 09ba902e2e37300b14634ea1d750f7e22afeeaf1
Intermittently unable to find init.tcl on Windows
User & Date: LordAro on 2025-11-26 16:34:01
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/x-markdown"
  4. comment changed to:
    I've run into a curious problem on Windows where TCL will intermittently be unable to find init.tcl, but with the error "No error", which is especially unhelpful:
    
    ```
    >       self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    E       _tkinter.TclError: Can't find a usable init.tcl in the following directories: 
    E           {C:\builds\m6srz7K6C\0\dev\rvs\rvs\auxd\python\tcl\tcl8.6}
    E       
    E       C:/builds/m6srz7K6C/0/dev/rvs/rvs/auxd/python/tcl/tcl8.6/init.tcl: couldn't read file "C:/builds/m6srz7K6C/0/dev/rvs/rvs/auxd/python/tcl/tcl8.6/init.tcl": No error
    E       couldn't read file "C:/builds/m6srz7K6C/0/dev/rvs/rvs/auxd/python/tcl/tcl8.6/init.tcl": No error
    E           while executing
    E       "source C:/builds/m6srz7K6C/0/dev/rvs/rvs/auxd/python/tcl/tcl8.6/init.tcl"
    E           ("uplevel" body line 1)
    E           invoked from within
    E       "uplevel #0 [list source $tclfile]"
    E       
    E       
    E       This probably means that Tcl wasn't installed properly.
    ```
    
    So far this only happens on our CI build jobs on Windows (Server 2022, docker-windows & gitlab-runner), and only in maybe 1 in every 50 builds. I've had no luck in reproducing the issue locally. Defender is disabled within on the build machines (though I still wouldn't expect 'No error' for that).
    
    As the error comes from TCL itself and there's no multithreading involved as far as I'm aware (tests run via pytest) so I don't think it's anything directly to do with python/tkinter - there shouldn't even be any other processes running tcl at the same time, all entirely sequential.
    
    The relevant bit of source code that's running is:
    
    ```
    from tkinter import Tcl, TclError
    def run_tcl(filename: str, tcl_code: str) -> str:
        tcl = Tcl()
        try:
            return tcl.eval(tcl_code)
        except TclError as e:
            print(f"Error in Tcl code: {e}", filename)
    ```
    
    This has apparently been seen in the wild in a number of places, but mostly in the context of matplotlib, where the solution seems to be switching to a different backend (Agg) that doesn't use tkinter. Obviously this isn't viable for me as I'm running TCL code directly.
    
    * https://stackoverflow.com/questions/71443540/intermittent-pytest-failures-complaining-about-missing-tcl-files-even-though-the
    * https://github.com/actions/setup-python/issues/1102
    * https://github.com/microsoft/azure-pipelines-tasks/issues/16426
    * https://github.com/orgs/community/discussions/26434
    * https://github.com/matplotlib/matplotlib/issues/29119
    
    For reference, I've seen it when running via pytest 8.4.2 on CPython 3.13.9 (with a build from https://github.com/astral-sh/python-build-standalone), which has (a threaded build of) TCL 8.6.12, but has been seen on 3.12.10 as well (and judging by the other links, plenty of other versions too)
    
    I've had a good search of this bug tracker and the mailing list and haven't found anything particularly relevant. I realise this is a bit of a brain dump and there isn't a huge amount to go on, but I've not got a lot! I don't have any real experience with TCL/TK, so if there's anything more I can turn on to debug this further (environment variables, etc) it would be greatly appreciated!
    
  5. foundin changed to: "8.6.12"
  6. is_private changed to: "0"
  7. login: "LordAro"
  8. priority changed to: "5 Medium"
  9. private_contact changed to: "f5960d8c42a209f0c1345190d692f076bf24aaa0"
  10. resolution changed to: "None"
  11. severity changed to: "Important"
  12. status changed to: "Open"
  13. submitter changed to: "LordAro"
  14. subsystem changed to: "38. Init - Library - Autoload"
  15. title changed to: "Intermittently unable to find init.tcl on Windows"
  16. type changed to: "Bug"