Version 17 of TCLLIBPATH

Updated 2008-10-07 15:16:13 by LV

Purpose: to document the use of another of the magic names in Tcl. More formally, TCLLIBPATH is an environment variable; inside Tcl you can retrieve it with $::env(TCLLIBPATH).

What is its purpose?

To provide user specified locations to add to the package search path.

What is its format?

A tcl list of directory paths (unix-style paths for Win32 users). e.g: set TCLLIBPATH="/opt/tcl/site-lib /users/pat/working"

What are some good reasons to set it?

PT 20-Jul-2004: I like to keep all my local packages separate from the ActiveTcl installation that I use as a base. So I install all additional packages to a site-lib directory and then set TCLLIBPATH to this directory path. With this in place a [package require XYZ] command will search ActiveTcl and my site-lib directory for the most recent version of XYZ.

* test a package without installing.

What else?

D. McC 08-Nov-2004: Well ... what about this?

 [david@localhost david]% puts $::env(HOME)

/home/david

 [david@localhost david]% puts $::env(TCLLIBPATH)

can't read "::env(TCLLIBPATH)": no such variable

This happens on my Mandrake linux 10.0 system, running Tcl 8.4 from the tcl-8.4.5-3mdk RPM package. Why no TCLLIBPATH, I wonder?

RS: Because nobody has set it? :-) Normally it's best to use as few env variables as possible - it should only be used to override some default behavior, which for finding libs is:

 [file dir [info nameofexe]]/../lib

and similar variations.

LV David, environmental variables are ones that someone external to Tcl set. In many cases, they are set by a user. In a few cases, a shell command or some other utility (such as Modules for instance), may set the environment variables. So many times, one won't find them set. This is different than magic names like the $argc variable, etc.


See also TCL_LIBRARY, auto_path.