Updated 2016-05-21 04:40:35 by pooryorick

$env(TCLLIBPATH) is a list of directories to add to $auto_path, which in turn is used by facilities such as package unknown to search for packages.

See Also  edit

auto_path
magic names
$env(TCL_LIBRARY)

Description  edit

$env(TCLLIBPATH) is a Tcl list, not some platform-specific colon-separated or semi-colon separated format, of paths to prepend to $auto_path. Regardless of platform, Each item in $env(TCLLIBPATH) should use / to delimit parts of a path.

Example:
set env(TCLLIBPATH) [list /opt/tcl/site-lib /users/pat/working]

$env(TCLLIBPATH) is often not set by Tcl, and is designed to be set on a case-by-case basis depending on the needs of the site or the individual user to provide Tcl with additional site-specific locations to search for packages, or to test a package without installing it.

 Further Discussion and Examples

PT 2004-07-20:

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 $env(TCLLIBPATH) to this directory path. With this in place package require XYZ searches ActiveTcl and my site-lib directory for the most recent version of XYZ.

Determining which directory to add to TCLLIBPATH  edit

LV 2009-06-29:

I download a package onto my machine. The package has a README, a demo directory, a lib directory, etc. Within the lib directory I see 3 sub-directories, and within the sub-directories are the pkgIndex.tcl file, etc.

So the basic layout is:
Installation directory/
 README.txt
 demos/
 lib/
  package1/
    pkgIndex.tcl 
  package2/
    pkgIndex.tcl
  package3/
    pkgIndex.tcl
 src/
 tests/

So, what path(s) go into TCLLIBPATH? the path to the lib/, or each of the individual packages?

Thanks!

PT: the lib directory.

LV PT, thank you for the answer. I tried using that, and ran into my long time nemesis - Windows folders with spaces in the names. So eventually, when I have time, I need to change to using file join to set $env(TCLLIBPATH) rather than just hard coding it, so that it has some chance of working.

Example: Windows with Git version 1.7.10-preview20120409  edit

LGT:

I ran git, then do 'cd' to be in HOME directory and then add file .bashrc with these lines:
$ cd
$ cat .bashrc
TCLLIBPATH=" . C:/Tcl/lib"
export TCLLIBPATH
$ 

Then at the next start of git, you will be able to use library packages from external (to git) Tcl installation (for instance Activestate Tcl).

Space character seems to be required at the beginning of $env(TCLLIBPATH): you can try the following lines on command line to experience it
$ unset TCLLIBPATH
$ TCLLIBPATH=". C:/Tcl/lib"
$ export TCLLIBPATH
$ tclsh
% package require Expect
can't find package Expect
% exit
$ TCLLIBPATH=" . C:/Tcl/lib "
$ export TCLLIBPATH
$ tclsh
% package require Expect
5.43.2
% exit
$

PYK 2014-05-23: This statement about the space character doesn't sound plausible. Could someone confirm or deny ? APN Works for me without the space. At least for 8.6.0.

DKF: It's a Tcl list. That should tell you exactly how to make things work, and should also indicate that leading and trailing whitespace will be ignored.