Artifacts Associated With Ticket 75ecc0e6cb
Ticket change [2be723385e] (rid 163651) by sebres on 2018-05-30 18:53:55:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/x-fossil-wiki"
- comment initialized to:
Set the system encoding via environment/locale failed somitimes dependent of the system constellation (distribution and/or some env-settings). Who saw already the test "unixInit-3.2" failed? :) This cumulates from two actual issues: 1. setlocale (called from TclpInitPlatform) may overwrite environment "LANG" (to "C"), so the try searching of current encoding later in Tcl_GetEncodingNameFromEnvironment <b>will failback to "C"</b> (so the call of "setlocale" takes place <b>too early</b> in some cases, resp. get initial environment via getenv("LANG") <b>too late</b>); 2. second thing which can happen, if 1st issue with "setlocale" gets repaired, would be the fact, that Tcl_GetEncodingSearchPath (called from TclpSetInitialEncodings/Tcl_SetSystemEncoding) may return "" <b>before still any interpreter instance created</b> (and it is so if TclpInitPlatform called).<br/> In this case setting of something other as already available system-encodings going to "C" (iso8859-1), because the load of encoding simply fails.<br/> The reason for this trouble is the wrong value returned by callback TclpInitLibraryPath.<br/> But later (after first interp going created) the init.tcl (as well as the counterpart script hard-coded in Tcl_Init) will indirectly call Tcl_SetEncodingSearchPath to the proper value (after tcl_library correct resolved and TclGetProcessGlobalValue(&libraryPath) returns correct value) and then the load of the same encoding works. Following code can illustrate this behavior: <pre style="padding-left:10pt"><code> $ echo 'puts ==[encoding system]; encoding system euc-jp; puts ==[encoding system]' | LANG=japanese ./tclsh ==iso8859-1 ==euc-jp </code></pre> But setting of proper tcl_library env-variable resolves it: <pre style="padding-left:10pt"><code> $ echo 'puts ==[encoding system]; encoding system euc-jp; puts ==[encoding system]' | LANG=japanese TCL_LIBRARY=../library ./tclsh ==euc-jp ==euc-jp </code></pre> I saw it already too often, but following cases are affected especially: - usage of portable-like (not installed) tcl's instance or tcl-ed applications (where TCL_LIBRARY environment variable does not set by start); - call of other tcl-instance from tcl-app via [open "| some-tcl-app"] inside the tcl-interpterer with changed environment (LC_... resp. LANG are changed); - call of tcl from development environment (also not istalled), like this: <pre style="padding-left:10pt"><code> $ cd ~projects/tcl8.6/unix $ LD_LIBRARY_PATH=. ./tclsh ../tests/all.tcl -file '*unixInit*' -match '*unixInit-3.2*' ... ==== unixInit-3.2 TclpSetInitialEncodings FAILED ... ---- Result was: 1 ---- Result should have been (exact matching): 0 ==== unixInit-3.2 FAILED ... </code></pre> I've localized the "wrong" places and will try to fix it soon.<br/> WiP. - foundin initialized to: ">= 8.5 (partially), >= 8.6"
- is_private initialized to: "0"
- login: "sebres"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- severity initialized to: "Severe"
- status initialized to: "Open"
- submitter initialized to: "sebres"
- subsystem initialized to: "38. Init - Library - Autoload"
- title initialized to:
TclInitSubsystems issues: sporadical the lack of of encodings
- type initialized to: "Bug"
Ticket change [e7e3c1be72] (rid 163652) by sebres on 2018-05-30 18:54:09:
- assignee changed to: "sebres"
- login: "sebres"
- mimetype: "text/plain"
Ticket change [362596a403] (rid 163653) by sebres on 2018-05-30 18:54:54:
- login: "sebres"
- mimetype: "text/plain"
- title changed to:
TclInitSubsystems issues: the sporadic lack of encodings
Ticket change [4e5e428adf] (rid 163675) by sebres on 2018-05-31 13:50:42:
- comment changed to:
Set the system encoding via environment/locale failed sometimes dependent of the system constellation (distribution and/or some env-settings). Who saw already the test "unixInit-3.2" failed? :) This cumulates from two actual issues: 1. setlocale (called from TclpInitPlatform) may overwrite environment "LANG" (to "C"), so the try searching of current encoding later in Tcl_GetEncodingNameFromEnvironment <b>will failback to "C"</b> (so the call of "setlocale" takes place <b>too early</b> in some cases, resp. get initial environment via getenv("LANG") <b>too late</b>); 2. second thing which can happen, if 1st issue with "setlocale" gets repaired, would be the fact, that Tcl_GetEncodingSearchPath (called from TclpSetInitialEncodings/Tcl_SetSystemEncoding) may return "" <b>before still any interpreter instance created</b> (and it is so if TclpInitPlatform called).<br/> In this case setting of something other as already available system-encodings going to "C" (iso8859-1), because the load of encoding simply fails.<br/> The reason for this trouble is the wrong value returned by callback TclpInitLibraryPath.<br/> But later (after first interp going created) the init.tcl (as well as the counterpart script hard-coded in Tcl_Init) will indirectly call Tcl_SetEncodingSearchPath to the proper value (after tcl_library correct resolved and TclGetProcessGlobalValue(&libraryPath) returns correct value) and then the load of the same encoding works. Following code can illustrate this behavior: <pre style="padding-left:10pt"><code> $ echo 'puts ==[encoding system]; encoding system euc-jp; puts ==[encoding system]' | LANG=japanese ./tclsh ==iso8859-1 ==euc-jp </code></pre> But setting of proper tcl_library env-variable resolves it: <pre style="padding-left:10pt"><code> $ echo 'puts ==[encoding system]; encoding system euc-jp; puts ==[encoding system]' | LANG=japanese TCL_LIBRARY=../library ./tclsh ==euc-jp ==euc-jp </code></pre> I saw it already too often, but following cases are affected especially: - usage of portable-like (not installed) tcl's instance or tcl-ed applications (where TCL_LIBRARY environment variable does not set by start); - call of other tcl-instance from tcl-app via [open "| some-tcl-app"] inside the tcl-interpterer with changed environment (LC_... resp. LANG are changed); - call of tcl from development environment (also not istalled), like this: <pre style="padding-left:10pt"><code> $ cd ~projects/tcl8.6/unix $ LD_LIBRARY_PATH=. ./tclsh ../tests/all.tcl -file '*unixInit*' -match '*unixInit-3.2*' ... ==== unixInit-3.2 TclpSetInitialEncodings FAILED ... ---- Result was: 1 ---- Result should have been (exact matching): 0 ==== unixInit-3.2 FAILED ... </code></pre> I've localized the "wrong" places and will try to fix it soon.<br/> WiP. - icomment:
The branch "<a href="https://core.tcl.tk/tcl/timeline?r=fix-initsubsystem-75ecc0e6cb9899bf">fix-initsubsystem-75ecc0e6cb9899bf</a>" provides a fix for this ticket (for 8.6th). All tests passed on my reference systems (*nix as well as windows).
- login: "sebres"
- mimetype: "text/x-fossil-wiki"
- comment changed to:
Ticket change [021ac42b0d] (rid 163676) by sebres on 2018-05-31 14:15:37:
- icomment:
BTW There is a new C-routine "TclpExtendWithRelativeLibraryPaths" now, which could be used later as replacement for some hard-coded script-parts of the tclInit (which belong to parents relative the path of "nameofexecutable"). I mean this scripts:<code><pre style="padding-left: 10pt"> file join $parentDir lib tcl[info tclversion] file join $grandParentDir lib tcl[info tclversion] file join $parentDir library file join $grandParentDir library file join $grandParentDir tcl[info patchlevel] library file join [file dirname $grandParentDir] tcl[info patchlevel] library </pre></code> Indirectly TclpExtendWithRelativeLibraryPaths returns all valid (existing) paths of above-mentioned combinations in the same sequence.
- login: "sebres"
- mimetype: "text/x-fossil-wiki"
- icomment:
Ticket change [03809c58a5] (rid 207159) by jan.nijtmans on 2022-11-22 19:44:35:
- icomment: "This came up again. See: [fccb9f322]"
- login: "jan.nijtmans"
- mimetype: "text/x-fossil-wiki"
Ticket change [7e873e51c1] (rid 258283) by serhiy.storchaka on 2026-10-16 20:52:31:
- foundin changed to: "8.6.18, 9.1.0"
- icomment:
The system-encoding part was fixed in 9.0 by [17c53b7edd]; 8.6 still shows it for an uninstalled or relocated tclsh. On main, TIP 732 dropped the <nowiki>[encoding dirs]</nowiki> addition from init.tcl, so a --disable-zipfs tclsh with a relocated library has no encoding directories at all (9.1.0). Proposed fix in branch [/timeline?r=init-encoding-dirs|init-encoding-dirs], test encoding-26.1.
- login: "serhiy.storchaka"
- mimetype: "text/x-fossil-wiki"
Ticket change [a8379bc004] (rid 258358) by dgp on 2026-10-16 22:41:00:
- icomment:
I thought one of the intents of TIP 732 was to simplify and reduce the search paths. Before growing them again, someone involved in TIP 732 should comment.
- login: "dgp"
- mimetype: "text/plain"
- icomment:
Ticket change [49b02f7691] (rid 258452) by serhiy.storchaka on 2026-10-17 07:30:00:
- icomment:
It does not grow the search path, it restores what 9.0 does: init.tcl adds <nowiki>[file join $::tcl_library encoding]</nowiki> to <nowiki>[encoding dirs]</nowiki> if it is not there. TIP 732 ([83e88416ac]) moved that part of init.tcl to InitAutoPathObjCmd(), whose comment still says "The function also adds the encoding subdirectory of tcl_library to the encodings search path if not already present", but the code was not moved. So in 9.1 a tclsh without zipfs whose library is not at the compiled-in place has no encoding directories at all. @apnadkarni, was dropping it intended?
- login: "serhiy.storchaka"
- mimetype: "text/x-fossil-wiki"
- icomment:
Ticket change [8e256e9b83] (rid 258628) by apnadkarni on 2026-10-17 16:53:24:
- assignee changed to: "apnadkarni"
- icomment:
I have to retrace but will need some time before I can look at it. I vaguely recall it was supposed to be done elsewhere (which would mean the comment was not fixed) but I could be wrong.
- login: "apnadkarni"
- mimetype: "text/plain"
Ticket change [c4744a30a5] (rid 261258) by apnadkarni on 2026-11-06 15:40:08:
- icomment:
Proposed fix in branch [apn-bug-75ecc0e6cb](https://core.tcl-lang.org/tcl/timeline?r=apn-bug-75ecc0e6cb). Implementation differs from the init-encoding-dirs branch. Encoding directory should be added irrespective of whether `InitAutoPath` is called by a (custom) init.tcl or not so it's called from `LocatePreInitScript` which sets `tcl_library`. Implementation is shared with the zipfs enabled case. Question, in case anyone feels one way or another - - new encoding dirs are added to the front, not the back (the new encoding-26.1 test has been modified accordingly). My thinking is directories added later by any mechanism should be searched to earlier ones. Easy enough to change. - After an application sets the encoding directories through `encoding dirs` new interpreters will modify the search path established through that command. I don't know if that is desirable or not but that is the 8.6 behaviour and preserved.
- login: "apnadkarni"
- mimetype: "text/x-markdown"
- icomment:
Ticket change [32e8d4c586] (rid 261276) by apnadkarni on 2026-11-07 11:08:42:
- closedate changed to: "2461351.9643800231"
- closer changed to: "apnadkarni"
- icomment:
Merged into 9.1 in [1bc3a58eac]. Not applicable to 9.0. Please re-open if you still see an issue.
- login: "apnadkarni"
- mimetype: "text/x-fossil-plain"
- resolution changed to: "Fixed"
- status changed to: "Closed"