Installing Tcl/Tk on Ubuntu

This information may also apply to other Debian-based Linux distributions. I don't know.

LES in September, 2009: I have been running Ubuntu for some time and, although it has many notable qualities, I don't consider it a very Tcl-friendly distro. What annoys me is that some of the applications available in the official repositories require Tcl and/or Tk as a dependency, and each application requires a certain version of Tcl. Ubuntu will fulfill the requirement exactly, i.e. Tcl 8.4 will be installed if the application requires it even if 8.5 would work just the same. Therefore, you may end up with two versions of Tcl installed. I still haven't run across any application that requires 8.3, but 8.6 is publicly available already. If you decide to install 8.6, you may end up having three versions of Tcl on Ubuntu: 8.4, 8.5 and 8.6.

That is not only messy, there are not many Tcl/Tk packages available in the official repositories, some of them may be outdated or even buggy (e.g. one of my Tk applications plays sounds, but sound stops working after some time and I have to restart the app). You may prefer to install ActiveTcl, for example, for its thourough and up-to-date collection of packages if nothing else. Or you may want to compile from source.

If you install ActiveTcl or compile from source, note that Ubuntu may "overwrite" your installation, i.e. other binaries will be installed (probably not where you chose to install your choice of Tcl distribution) and the system will be updated to refer to those binaries instead of the ones you prefer. You may end up running an older version of Tcl/Tk all the time if you don't pay attention. Conversely, if you fulfill the dependencies first and install your favorite flavor of Tcl/Tk later, Ubuntu will not acknowledge your choice automatically. For that reason, I recommend the following procedure:

  1. Install both Tcl/Tk 8.4 and 8.5 from the official Ubuntu repositories, so you have those dependencies fulfilled in case some application requires them in the future, so Ubuntu won't "overwrite" your installation.
  2. You may want to select and install all Tcl-related packages just in case. I usually don't.
  3. Install ActiveTcl or your favorite distribution or compile source and 'make install'.
  4. Run these command lines as root or with sudo:
 update-alternatives --install tclsh tclsh /opt/path/to/Tcl/bin/tclsh8.5 5

 update-alternatives --install tclsh wish /opt/path/to/Tcl/bin/wish8.5 5

The trailing number 5 is arbitrary. It determines priority above other choices. I don't think it matters, it just has to be there or the command will not work. Refer to 'man update-alternatives' for more information. After that, run these command lines:

 update-alternatives --config tclsh

 update-alternatives --config wish

In either case, you will be prompted to choose from a menu. Choose the path to the installation you want to have as default on your system, and that's it.


LV Some people find that installing ActiveTcl in a non-OS maintained location keeps the distribution from being overwritten. If you choose that option, be certain to update your $PATH and $MANPATH environment variables to include the new location BEFORE the OS default location. If you choose this option, you may find you also need to update an environmental variable for libraries, such as $LD_LIBRARY_PATH or something similar. If so, please update this page to indicate that.

LES I said "overwrite" in quotes since it it not really overwritten if you avoid the default paths. In my machine, Ubuntu installed Tcl 8.4 in /usr/bin/tclsh8.4, /usr/lib/libtcl8.4.so.0 and a lot of support files in /usr/share/tcltk/tcl8.4/*. The same for 8.5, except the version numbers. It won't touch your binaries if you install them in /opt for example. It just overwrites the settings that determine which installation of Tcl is in force throughout the system.


SEH 20130829 -- I just installed Ubuntu 12.04 on a Windows laptop using the Wubi installer [L1 ]:

Wubi is an official Windows-based free software installer for Ubuntu, which installs the 
software on an existing Windows partition, thus without need for partitioning.

The project's aim is to enable existing Windows users, unacquainted with Linux, to try 
Ubuntu without risking any data loss (due to disk formatting or partitioning mistakes).
It can also safely uninstall Ubuntu from within Windows.

It is not a virtual machine, but creates a stand-alone installation within a loopmounted 
device, also known as a disk image.

I then tried to use the ActiveTcl installer, as I have many times before, to install Active Tcl 8.6. Strangely, it appears that none of the executables in the install distro can recognize the existence of any other files on the pseudo drive on which Ubuntu is installed. When I try to run install.sh, it fails because wish thinks install.tk doesn't exist. When I apt-get installed wish, I could run install.tk and install the distro successfully. But when I try to run any of the shells from the install bin directory, I get a cryptic "not found" error.

Is there some special sauce that has to be added to a compile that allows files to be read from a loop mounted device? And can that sauce be added to Active Tcl?