пятница, 15 октября 2021 г. в 15:40:05 UTC+3, Schelte:
> On 15/10/2021 13:25, Oleg O. Nemanov wrote:
> > Sorry. The wrong info :-). In 8.6.11 the same stranges.
> >
> There must be some misbehaving package on your system. Executing
> [package require test] causes all pkgIndex.tcl files found under the
> directories in $auto_path to be executed. These files are not supposed
> to have any side-effects, other than updating the list of available
> packages via [package provide] commands. But apparently one of the files
> does something more.
>
> You can investigate by running [package names] before and after you do
> [package require test]. For each of the packages that newly appear, run
> [package versions <pkg>]. Then for each of the available versions of a
> suspected package, find the pkgIndex.tcl file and examine it.
Before ```llength [package names]``` returns 4, after - 448 :-).
> You can narrow down the culprit by removing directories from $auto_path
> before doing the [package require test]. If that solves the problem, the
> rogue package is below one of the directories you removed.
I set auto_path to only one empty dir and load behaviour isn't changed(before
package require and after it load successfully load a lib in current dir).
After that, i set auto_path to only /usr/lib/tcl8.6 and load behaviour is changed.
But here only 2 pkgIndex.tcl files:
/usr/lib/tcl8.6/http1.0/pkgIndex.tcl
/usr/lib/tcl8.6/opt0.4/pkgIndex.tcl
~$ cat /usr/lib/tcl8.6/http1.0/pkgIndex.tcl
# Tcl package index file, version 1.0
# This file is generated by the "pkg_mkIndex" command
# and sourced either when an application starts up or
# by a "package unknown" script. It invokes the
# "package ifneeded" command to set up package-related
# information so that packages will be loaded automatically
# in response to "package require" commands. When this
# script is sourced, the variable $dir must contain the
# full path name of this file's directory.
package ifneeded http 1.0 [list tclPkgSetup $dir http 1.0 {{http.tcl source {httpCopyDone httpCopyStart httpEof httpEvent httpFinish httpMapReply httpProxyRequired http_code http_config http_data http_formatQuery http_get http_reset http_size http_status http_wait}}}]
~$ cat /usr/lib/tcl8.6/opt0.4/pkgIndex.tcl
# Tcl package index file, version 1.1
# This file is generated by the "pkg_mkIndex -direct" command
# and sourced either when an application starts up or
# by a "package unknown" script. It invokes the
# "package ifneeded" command to set up package-related
# information so that packages will be loaded automatically
# in response to "package require" commands. When this
# script is sourced, the variable $dir must contain the
# full path name of this file's directory.
if {![package vsatisfies [package provide Tcl] 8.2]} {return}
package ifneeded opt 0.4.6 [list source [file join $dir optparse.tcl]]
In http pkgIndex.tcl file i placed right after comments:
puts "1"
load libsetval.so
In opt pkgIndex.tcl file i placed right after comments:
puts "2"
load libsetval.so
After that i do:
~$ tclsh
% set auto_path /usr/lib/tcl8.6
/usr/lib/tcl8.6
% package require test
1
error reading package index file /usr/lib/tcl8.6/http1.0/pkgIndex.tcl: couldn't load file "libsetval.so": libsetval.so: cannot open shared object file: No such file or directory
2
error reading package index file /usr/lib/tcl8.6/opt0.4/pkgIndex.tcl: couldn't load file "libsetval.so": libsetval.so: cannot open shared object file: No such file or directory
can't find package test
%
I.e. load behaviour is changed before any statements in pkgIndex.tcl.