Tcl Source Code

View Ticket
Login
Ticket UUID: 6b3618ed9363e6038df3efc113093eef9a86323c
Title: can't find package opt 0.1
Type: Bug Version: 8.6.8
Submitter: anonymous29 Created on: 2018-08-03 05:55:24
Subsystem: - New Builtin Commands Assigned To: nobody
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2018-08-06 05:27:19
Resolution: Invalid Closed By: anonymous29
    Closed on: 2018-08-06 05:27:19
Description:
i am updating tcl from 8.4.13 to 8.6.8. 
i am getting error "can't find package opt 0.1". 
when i replace 
package unknown {::tcl::tm::UnknownHandler ::tclPkgUnknown} 
by
package unknown {tclPkgUnknown}
in init.tcl file, 
No error seen. 
How can i fix this error ?
User Comments: anonymous29 added on 2018-08-06 05:27:19:
Thanks a lot sebres. 
Your comments and suggestion was very help full to debug this issue. 
This is porting issue.

sebres added on 2018-08-04 22:29:02:

I cannot follow what you try to source here...

Anyway if it is all what you see there, you have something other as normal Tcl-installation (some special project-based build or similar). I think your init.tcl/package.tcl are not the default version (or injected by the project, or something similar). Or just the program you trying to use is not default tcl (so can do another things as in standard release like manipulate auto_path, rewrite loading mechanisms, etc). For example why your prompt started with `>` (in opposite to tclsh/wish/etc where it is `%`)?

Below you'll find how it looks on mainstream tcl8.6 by `package require opt`:

% package require opt
** DBG:        ** ::source /path-to-tcl/library/history.tcl **
** DBG:        ** [OK] **
** DBG:        ** ::source /path-to-tcl/library/tm.tcl **
** DBG:        ** [OK] **
** DBG:        ** ::source /path-to-tcl/library/package.tcl **
** DBG:        ** [OK] **
** DBG:    ** ::source /path-to-tcl/library/http/pkgIndex.tcl **
** DBG:    ** [OK] **
** DBG:    ** ::source /path-to-tcl/library/http1.0/pkgIndex.tcl **
** DBG:    ** [OK] **
** DBG:    ** ::source /path-to-tcl/library/msgcat/pkgIndex.tcl **
** DBG:    ** [OK] **
** DBG:    ** ::source /path-to-tcl/library/opt/pkgIndex.tcl **
** DBG:    ** [OK] **
** DBG:    ** ::source /path-to-tcl/library/platform/pkgIndex.tcl **
** DBG:    ** [OK] **
...
** DBG:  ** ::source /path-to-tcl/library/opt/optparse.tcl **
** DBG:  ** [OK] **
0.4.6

Normally if tcl evaluates `package require`, it will load package.tcl and hereafter all pkgIndex.tcl in all directories from `auto_path`. So it will know where each package is placed and what it has to do to load this package.

But in your case it's totally different. So I assume you use something else (a special build).

So you should generate the package structure (resp. architecture of pkgIndex-load mechanism) how it is expected from this build/project.

Or just stay on 8.4.

Neither we have the knowledge how your project/app handles this all, nor this will be possible without take a look into whole project infrastructure (e.g. I see strobe.tcl loaded as first directly in init.tcl or even this file xmsimrc you tried to source, both are unknown to me).

Therefore we cannot help you here, thus closed as 3rd party issue.


anonymous29 added on 2018-08-03 18:57:45:
Hi,
Getting below output after adding (2. More complex try:)

** DBG:      ** ::source /dv/p4users06nd/arvindk/tcl16/dvproject/dep/tools/inca/files/tcl/library/strobe.tcl **
** DBG:      ** [OK] **
> source /dv/p4users06nd/arvindk/tcl16/dvproject/dep/tools/inca/files/xmsimrc
** DBG:        ** ::source /dv/p4users06nd/arvindk/tcl16/dvproject/dep/tools/inca/files/tcl/library/history.tcl **
** DBG:        ** [OK] **
** DBG:  ** ::source /dv/p4users06nd/arvindk/tcl16/dvproject/dep/tools/inca/files/xmsimrc **
** DBG:  ** [OK] **

> package require opt
can't find package opt.

> exit

Thanks,

sebres added on 2018-08-03 14:46:28:

So it works by direct loading of package index... The question is: why does not work on demand.

It looks like some module tries to load package opt (possibly on demand within pkgIndex/tclIndex) BEFORE auto_path is properly set, or just some similar issue.

1. Simple try (as already said in my first comment):

Also to find the possible evil-doers search inside tcl-library for "opt 0.1" (maybe even with "-exact" prefixed).

2. More complex try:
Insert following code into begin of init.tcl and try again to start or do package require opt...
## ----------------------------------------------------------------------------
## inject to trace all-sources:
if {[namespace which -command ::_org_source] eq ""} {
  rename ::source ::_org_source
  proc ::source {args} {
    ::puts "** DBG:[string repeat "  " [info level]]** [linsert $args 0 ::source] **"
    if {[catch {
      uplevel 1 [linsert $args 0 [set args ::_org_source]]
    } err opt]} {
      ::puts "** ERR: $::errorInfo"
      return {*}$opt $err
    }
    ::puts "** DBG:[string repeat "  " [info level]]** \[OK\] **"
  }
}
## /inject
## ----------------------------------------------------------------------------


anonymous29 added on 2018-08-03 13:32:35:
Actually both pkgIndex.tcl is same because 
/dv/p4users06nd/arvindk/tcl16/dvproject/dep/tools/inca/files/tcl/library/ is installation directory 
and there is symbolic link from installation directory to tcl source directory
(/dv/p4users06nd/arvindk/tcl16/dvproject/dep/tools/inca/files/tcl/library/opt/pkgIndex.tcl -> /dv/p4users06nd/arvindk/tcl16/inca/src/libs/tcl/library/opt/pkgIndex.tcl)
 
Terminal 1:
> set dir /dv/p4users06nd/arvindk/tcl16/dvproject/dep/tools/inca/files/tcl/library/opt; source $dir/pkgIndex.tcl
> package require opt
0.4.6
> exit

Terminal 2:
> set dir /dv/p4users06nd/arvindk/tcl16/inca/src/libs/tcl/library/opt; source $dir/pkgIndex.tcl
> package require opt
0.4.6
> exit

There is not any other opt directory

sebres added on 2018-08-03 11:49:34:

So I see at least 2 pkgIndex for opt:

  • /dv/p4users06nd/arvindk/tcl16/dvproject/dep/tools/inca/files/tcl/library/opt/pkgIndex.tcl
  • /dv/p4users06nd/arvindk/tcl16/inca/src/libs/tcl/library/opt/pkgIndex.tcl

Have you compared both (that are text/tcl-source)?...

Is there another package called opt?

If you loads it directly (specify dir-var to each directory), can you then use package:

set dir /dv/p4users06nd/arvindk/tcl16/dvproject/dep/tools/inca/files/tcl/library/opt; source $dir/pkgIndex.tcl
package require opt
and (in new shell):
set dir /dv/p4users06nd/arvindk/tcl16/inca/src/libs/tcl/library/opt; source $dir/pkgIndex.tcl
package require opt

If it's not your project/software where you tries to upgrade tcl, please contact the maintainer of this project/software.

For example some binaries could be not compatible anymore and should be rebuild. Additionally as already said if you have another (not tcl-default) package "opt", it should be renamed resp. all references corrected in the source code.


anonymous29 added on 2018-08-03 11:20:22:
Hi sebres,
below is the ouput of commands

> foreach p $::auto_path {
>   foreach p [glob -nocomplain -directory $p pkgIndex.tcl */pkgIndex.tcl] {puts $p}
> }
/dv/p4users06nd/arvindk/tcl16/dvproject/dep/tools/inca/files/tcl/library/tcltest/pkgIndex.tcl
/dv/p4users06nd/arvindk/tcl16/dvproject/dep/tools/inca/files/tcl/library/opt/pkgIndex.tcl
/dv/p4users06nd/arvindk/tcl16/inca/src/libs/tcl/library/dde/pkgIndex.tcl
/dv/p4users06nd/arvindk/tcl16/inca/src/libs/tcl/library/dde1.1/pkgIndex.tcl
/dv/p4users06nd/arvindk/tcl16/inca/src/libs/tcl/library/http/pkgIndex.tcl
/dv/p4users06nd/arvindk/tcl16/inca/src/libs/tcl/library/http1.0/pkgIndex.tcl
/dv/p4users06nd/arvindk/tcl16/inca/src/libs/tcl/library/http2.3/pkgIndex.tcl
/dv/p4users06nd/arvindk/tcl16/inca/src/libs/tcl/library/msgcat/pkgIndex.tcl
/dv/p4users06nd/arvindk/tcl16/inca/src/libs/tcl/library/msgcat1.0/pkgIndex.tcl
/dv/p4users06nd/arvindk/tcl16/inca/src/libs/tcl/library/opt/pkgIndex.tcl
/dv/p4users06nd/arvindk/tcl16/inca/src/libs/tcl/library/platform/pkgIndex.tcl
/dv/p4users06nd/arvindk/tcl16/inca/src/libs/tcl/library/reg/pkgIndex.tcl
/dv/p4users06nd/arvindk/tcl16/inca/src/libs/tcl/library/tcltest/pkgIndex.tcl

> source /dv/p4users06nd/arvindk/tcl16/inca/src/libs/tcl/library/opt/pkgIndex.tcl
can't read "dir": no such variable.
    while executing
"file join $dir optparse.tcl"
    (file "/dv/p4users06nd/arvindk/tcl16/inca/src/libs/tcl/library/opt/pkgIndex.tcl" line 12)
    invoked from within
"source /dv/p4users06nd/arvindk/tcl16/inca/src/libs/tcl/library/opt/pkgIndex.tcl"

> set ::errorInfo
can't read "dir": no such variable
    while executing
"file join $dir optparse.tcl"
    (file "/dv/p4users06nd/arvindk/tcl16/inca/src/libs/tcl/library/opt/pkgIndex.tcl" line 12)
    invoked from within
"source /dv/p4users06nd/arvindk/tcl16/inca/src/libs/tcl/library/opt/pkgIndex.tcl"

> package require opt
can't find package opt.

> set ::errorInfo
can't find package opt
    while executing
"package require opt"
> package vsatisfies [package provide Tcl] 8.2
1

> source [file join /dv/p4users06nd/arvindk/tcl16/inca/src/libs/tcl/library/opt optparse.tcl]

> set ::errorInfo
can't find package opt
    while executing
"package require opt"

> exit

Thanks

sebres added on 2018-08-03 09:54:50:
I suggested to test `package require opt` and not `package require opt 0.1`...

I don't completely understand what you try to explain here, so please provide the output of script I wrote below (starting with foreach p ...).
Or check that opt/pkgIndex.tcl is definitely in this output.

Additionally try to load this index directly:

% source <path>/tcl/library/opt/pkgIndex.tcl
% package require opt

if it fails, provide errorInfo.

You can also try to invoke the script parts defined as ifneeded in pkgIndex directly, like:

% package vsatisfies [package provide Tcl] 8.2
% source [file join <path>/tcl/library/opt optparse.tcl]

What do you see there? If it fails, provide errorInfo after each command that fails.

anonymous29 added on 2018-08-03 09:14:00:
<path>/tcl/library/opt/optparse.tcl means <path>/tcl8.6.8/library/opt/optparse.tcl

tcl -> tcl8.6.8

anonymous29 added on 2018-08-03 09:11:14:
Thanks sebres  for your comments

below is the out of command which u suggested  
> package require opt 0.1
can't find package opt 0.1

> set ::errorInfo
can't find package opt 0.1
    while executing
"package require opt 0.1"

> set ::auto_path
tools/inca/files/tcl/library
tools/inca/files/tcl
tools/lib
libs/tcl/library

Yes "opt/pkgIndex.tcl" present in <path>/tcl8.6.8 directory.
symbolic link present in tools/inca/files/tcl/library
i.e 
tools/inca/files/tcl/library/opt/pkgIndex.tcl -> <path>/tcl/library/opt/pkgIndex.tcl
tools/inca/files/tcl/library/opt/optparse.tcl -> <path>/tcl/library/opt/optparse.tcl

How can i use this information to debug further ?
Thanks

sebres added on 2018-08-03 08:26:07:
It looks like you may have a "broken" pkgIndex.tcl (or tclIndex) that avoid correct loading of all expected packages...
Or just a wrong dependencies or version conflict somewhere in your tcl-library.

Since 8.5 Tcl provides package opt with version >= 0.4. Do you see opt/pkgIndex.tcl somewhere?

What do you see if you evaluate `package require opt` in the tclsh?
If you get an error, what is the output of `set ::errorInfo`?

The order how the packages are loaded is dependend from `set ::auto_path`, this simple script provides output which they may be (not auto_path can be changed during loading process):

foreach p $::auto_path {
  foreach p [glob -nocomplain -directory $p pkgIndex.tcl */pkgIndex.tcl] {puts $p}
}

If you've another package with name opt, please remove or rename it (if it's your own).
Also to find the possible evil-doers search inside tcl-library for "opt 0.1" (maybe even with "-exact" prefixed).