| Ticket UUID: | dbde846f53311094d46091e5a2ebfc6de606bfdc | |||
| Title: | imap4 fails | |||
| Type: | Bug | Version: | 1.17 | |
| Submitter: | anonymous | Created on: | 2015-12-21 23:13:14 | |
| Subsystem: | imap4 | Assigned To: | aku | |
| Priority: | 7 High | Severity: | Important | |
| Status: | Open | Last Modified: | 2026-11-16 00:06:15 | |
| Resolution: | None | Closed By: | nobody | |
| Closed on: | ||||
| Description: |
There's an error when tring to import the imap4 package: package require imap4; Result was: can't read "argv0": no such variable | |||
| User Comments: |
serhiy.storchaka added on 2026-11-16 00:06:15:
Proposed fix in branch imap4-load-without-argv0: the check is now [info exists ::argv0] && [info script] eq $::argv0. Adds imap4.test, which loads the package without argv0 and from inside a proc. anonymous added on 2016-02-27 22:43:26: Hello aku,
Sorry for answering late.
I tried " if {[info exists argv0] && ([info script] eq $argv0)} {" but still getting : can't read "argv0": no such variable
The other wordaround works perfectly by the way.
I am using this in eggdrop which embeds Tcl, and therefore doesn't set argv0 at all, including the global variable. I agree that the test code should probably be moved somewhere else.
Regards.
aku added on 2015-12-27 16:13:19: Thank you. That code is apparently in imap4.tcl to detect if the package is run as the main script, and then to make it run as a simple example imap client application.
This is at the toplevel of the script, so that variable should exist, as far as I know. You are using tclsh to run your example, right ? (Or wish). Which version ? Can you show us the entire script you use which has the problem ? If not, then maybe a suitably shrunken version which still has the problem without leaking any confidential details of your setup and code ? ... I am wondering if you are using 'package require imap' from inside of a procedure. That might cause this issue.
Regardless of the answers, you have a workaround available to you.
Open the file mentioned in the stack trace you gave us, go to the end, the line 1297 where the if condition in question lurks, and disable the condition with a "0 &&" added to it, i.e like
if {0 && ([info script] eq $argv0)} {
That disables the condition and code, and should allow you to use the package.
An alternate possible fix would be
if {[info exists argv0] && ([info script] eq $argv0)} {
i.e. check if the variable exists.
That however feels a bit like simply papering over the problem. Which might be the tclsh you use somehow not creating the variable. Or maybe the 'require' weas invoked from inside a proc. The package code does not go to the global stack level. If that is the issue simply putting a
global argv0
before the if statement could solve the issue as well.
Ther proper fix (in my opinion) would be to move that entire piece of code out of the package into a separate and proper example application instead.
That however will have to wait until I am back from my x-mas vacation.
anonymous added on 2015-12-27 15:02:47: The error output is :
can't read "argv0": no such variable
while executing
"if {[info script] eq $argv0} {
# set imap4::debug 0
set FOLDER INBOX
set port 0
if {[llength $argv] < 3} {
puts "Usage: imap4...."
(file "/usr/share/tcltk/tcllib1.17/imap4/imap4.tcl" line 1297)
invoked from within
"source /usr/share/tcltk/tcllib1.17/imap4/imap4.tcl"
("package ifneeded imap4 0.5.2" script)
aku added on 2015-12-27 14:46:27: What is the output of puts $::errorInfo immediately after the failing 'package require' ? This might gives us a clue where the package tries to read argv0. Note, argv0 is one of Tcl's global variables, automatically defined by the tclsh/wish. It contains the name of the command running the Tcl script. Might be that imap simply tries to use it without either ::-prefix, or without brining it into scope via global argv0. | |||
Home
Blog
Docs
Downloads
Tickets
Timeline
Branches
Tags
Wiki