Repository navigation
🐛 fix(activate): preserve Tcl library path bytes - #3645
Merged
Merged
Conversation
Tcl can decode a library path with a different codec than the one used for activation scripts. Include a non-ASCII path only when its UTF-8 bytes match the current environment value. This keeps valid UTF-8 paths while avoiding a different directory after activation.
This was referenced Nov 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Activation generation at the merge base copied Tcl library text into scripts without checking whether its UTF-8 spelling matched the original path bytes. Under a legacy locale, activation could replace a user's working
TCL_LIBRARYwith a different directory and make a later Tcl program load files from that directory. The activators now include a non-ASCII path only when the current environment supplies the same bytes. This addresses draft advisory ANT-2026-174OWDGY.Tcl path text can lose its byte spelling
python-discovery queries
info librarywhenTCL_LIBRARYis set. Tcl checks that variable first for its startup library. The returned text can differ from the variable's original byte spelling in a legacy locale; Python's UTF-8 mode can also be active in the C locale. The template writer encoded that text as UTF-8. The destination check added in #3412 compares only the environment destination, so an ASCII destination does not stop this path change.Activation checks the original bytes
The shared library path check keeps ASCII paths and Windows behavior. For a non-ASCII POSIX path, it compares the text's UTF-8 bytes with the corresponding raw environment variable. If they differ or the variable is absent, the bash template's empty-value condition leaves the shell value alone. Bash, fish, nushell, and xonsh use the same check rather than replacing the base class values with unverified text. On POSIX, Xonsh decodes the original UTF-8 bytes at activation, using the active filesystem codec so a later locale change does not alter the exported path bytes.
flowchart LR D[Tcl library text] --> B[Before: write text as UTF-8] B --> X[Activation may use different path bytes] D --> C{Now: ASCII or Windows?} C -- yes --> W[Write path] C -- no --> E{UTF-8 bytes match current variable?} E -- yes --> W E -- no --> K[Leave shell value alone] classDef bad fill:#ffd6d6,stroke:#c1121f,color:#5c0000; classDef ok fill:#d8f3dc,stroke:#2d6a4f,color:#1b4332; class B,X bad; class C,E,W,K ok;Behavior changes
A non-ASCII
TCL_LIBRARYalready set in a UTF-8 environment remains available after activation. If the path text cannot be tied to the current variable, activation preserves the shell's existingTCL_LIBRARY; when it is unset, Tcl performs its normal library search. The same rule applies to generatedTK_LIBRARYvalues. A cached non-ASCII path is no longer restored when its source environment variable is absent. ASCII library paths and Windows generation keep their previous behavior.Reported by
oss-scanner: ANT-2026-174OWDGY.