Tcl Source Code

View Ticket
Login
Ticket UUID: 86ceb4e2b63cfcee65abade0ed16c9ce846b4e30
Title: package require searching module path in wrong order
Type: Bug Created on: 2013-07-15 05:47:53
Submitter: anonymous Assigned to: dgp
Subsystem: 39. Package Manager Severity: Minor
Priority: 5 Medium Last modified: 2013-09-08 12:18:31
Status: Closed Closed by: dgp
Resolution: Fixed Closed on: 2013-09-08 12:18:31
Version: 8.6
Description:

The tm documentation says that a module should be loaded from the module path by looking from the first in the list to the last. However I find that the opposite is happening. The problem can be demonstrated as so:

If I do:

  ::tcl::tm::path list

I get:
  /usr/lib/tcltk/tcl8/site-tcl /usr/lib/tcltk/tcl8/8.0
  /usr/lib/tcltk/tcl8/8.1 /usr/lib/tcltk/tcl8/8.2
  /usr/lib/tcltk/tcl8/8.3 /usr/lib/tcltk/tcl8/8.4
  /usr/lib/tcltk/tcl8/8.5 /usr/lib/tcltk/tcl8/8.6
  /usr/lib/tcl8/site-tcl /usr/lib/tcl8/8.0
  /usr/lib/tcl8/8.1 /usr/lib/tcl8/8.2
  /usr/lib/tcl8/8.3 /usr/lib/tcl8/8.4
  /usr/lib/tcl8/8.5 /usr/lib/tcl8/8.6
  /usr/share/tcltk/tcl8/site-tcl /usr/share/tcltk/tcl8/8.0
  /usr/share/tcltk/tcl8/8.1 /usr/share/tcltk/tcl8/8.2
  /usr/share/tcltk/tcl8/8.3 /usr/share/tcltk/tcl8/8.4
  /usr/share/tcltk/tcl8/8.5 /usr/share/tcltk/tcl8/8.6
  /usr/share/tcltk/tcl8.6/tcl8


If I create a file called: mymodtest-0.1.tm with the following contents:
  proc number {} {return 1}

I copy that file to the last location in the list above:
  /usr/share/tcltk/tcl8.6/tcl8

Then I edit the file, replace the 1 with a 2, and copy the file to the previous location in the list above:
  /usr/share/tcltk/tcl8/8.6

Finally I edit the file again, replace the 2 with a 3, and copy the file to the previous location in the list above:
  /usr/share/tcltk/tcl8/8.5

When I run the following script:
  package require mymodtest 
  number

I get a 1; if I delete the file from the last location in the list, I get a 2; if I then delete the file from the previous location I get a 3.

User Comments:
dgp added on 2013-07-15 17:14:55:
The TM search is working as documented.

Much more detail in the comp.lang.tcl followup.

https://groups.google.com/d/msg/comp.lang.tcl/VXsAUOlPIXY/dXu7-Hq8dusJ

dgp added on 2013-07-15 18:04:32:
Re-opened.

In that same comp.lang.tcl thread, Gustaf Neumann
suggests a tweak that might improve this situation
and related ones, yet still be faithful to the
assumptions in the [package require] design.

dgp added on 2013-07-15 19:11:22:
See branch bug-86ceb4e2b6 for an idea
how we might improve the experience of
the OP while not revising the assumptions
of [package require].

Thanks to Gustaf Neumann for the idea.

jan.nijtmans added on 2013-09-06 22:27:15:
This change looks good to me. Planned for 8.6.1?

dgp added on 2013-09-08 12:18:31:
Change accepted for 8.5.15 and 8.6.1.