Version 0 of Common Tcl Error Messages and Possible Explanations

Updated 2001-05-24 11:49:30

Purpose: for users and developers to list error messages they encounter in Tcl and for others to explain some of the possible causes (and solutions) for these msgs. See also Common Tk Error Messages and Possible Explanations.

In many cases, the Tcl error messages are so clear that by reading the words carefully, one can pretty much figure out what is needed. However, there are occasionally times when this is not the case. Also, sometimes the error msg in question is from the operating system, but it appears as though the error is coming from Tcl. This page is intended to provide some assistance in those cases.

From I start with these questions and answers:

  1. "not found" or "Command not found"

This error message comes from your shell, not Tcl. The script probably starts with a #! that is followed by a path to the Tcl interpreter that is too long for your system. Many Unix systems are limited to 32 characters (including the #!) in this regard. So, something like this will fail:

    #! /usr/home/homedir/very/long/path/tclsh

    # rest of script

You can either shorten the path by moving the tclsh executable to a different directory or by using symbolic links. Another option is to not specify the path at all. See the question "How do I make my script executable regardless of the location of tclsh?" for an example of how to do this.

  1. invalid command name "}"

You have probably commented out a line that ends with an open curly brace. See Question 12 for more info.

  1. missing close-brace

Your braces aren't balanced. Again, one likely, though perhaps non-obvious, reason is improperly commented lines. See Question 12.

  1. expected integer but got ...

This error occurs when the interpreter was trying to perform some mathematical operation that requires an integer value, but encountered a non-integer value. While this is pretty obvious when the value supplied is a floating point value or an alphabetic string, this error can be confusing when the value is something that may look like a valid integer - specifically numbers that have leading zeros. See the question How can I use numbers with leading zeros? for an explanation.

  1. "Undefined symbol: main" or similar

The message, which comes not from Tcl but from some tool in the build process, occurs when linking an application. It is probably because the application was written for a version of Tcl different from the one you are linking against.

Older versions of Tcl included a main function in the library (libtcl.a). This caused various problems, in particular with C++ programs, and it was removed starting with version 7.4b1. The application being linked with the Tcl library must now provide the main routine itself.