The context: I am working on a kind of git frontend, which should have the capability to launch gitk and git-gui, both tcl/tk programs. It works fine on a regular linux but it gets problematic when working inside a snap container
In a snap container, the root of the filesystem is prefixed by the snap container path, so that the path to tck/tk libraries is now:
/snap/multigit/x21/usr/share/tcltk/tcl8.6
/snap/multigit/x21/usr/share/tcltk/tk8.6
In theory, tcl has a mechanism to deal with this. In practice, I failed to make it work. All examples listed are executed inside the snap container.
Without any adjustments, it looks like that:
osboxes@osboxes:/snap/multigit/x21/usr/share/tcltk$ gitk
application-specific initialization failed: Can't find a usable init.tcl in the following directories:
/usr/share/tcltk/tcl8.6 /snap/multigit/x21/usr/lib/tcl8.6 /snap/multigit/x21/lib/tcl8.6 /snap/multigit/x21/usr/library /snap/multigit/x21/library /snap/multigit/x21/tcl8.6.12/library /snap/multigit/tcl8.6.12/library
This probably means that Tcl wasn't installed properly.
Error in startup script: can't find package Tk
while executing
"package require Tk"
(file "/snap/multigit/x21/usr/bin/gitk" line 10)
That one is clear, I need to point TCL to its library location and there is a variable for this: TCL_LIBRARY
Let's point it to the common directory for tcl and tk:
osboxes@osboxes:/snap/multigit/x21/usr/share/tcltk$ export TCL_LIBRARY="/snap/multigit/x21/usr/share/tcltk"
And then:
osboxes@osboxes:/snap/multigit/x21/usr/share/tcltk$ gitk
application-specific initialization failed: Can't find a usable init.tcl in the following directories:
/snap/multigit/x21/usr/share/tcltk /snap/multigit/x21/usr/share/tcl8.6 /usr/share/tcltk/tcl8.6 /snap/multigit/x21/usr/lib/tcl8.6 /snap/multigit/x21/lib/tcl8.6 /snap/multigit/x21/usr/library /snap/multigit/x21/library /snap/multigit/x21/tcl8.6.12/library /snap/multigit/tcl8.6.12/library
This probably means that Tcl wasn't installed properly.
Error in startup script: can't find package Tk
while executing
"package require Tk"
(file "/snap/multigit/x21/usr/bin/gitk" line 10)
Not sufficient!
Let's point it to the directory for tcl library:
osboxes@osboxes:/snap/multigit/x21/usr/share/tcltk$ export TCL_LIBRARY="/snap/multigit/x21/usr/share/tcltk/tcl8.6"
osboxes@osboxes:/snap/multigit/x21/usr/share/tcltk$ gitk
Error in startup script: can't find package msgcat
while executing
"package require msgcat"
(file "/snap/multigit/x21/usr/bin/gitk" line 12279)
osboxes@osboxes:/snap/multigit/x21/usr/share/tcltk$
It's much better, the tcl library were loaded and gitk could start executing. But it misses msgcat. Where is it ?
osboxes@osboxes:/snap/multigit/x21/usr/share/tcltk$ find . | grep msgcat
./tcl8.6/tcl8/msgcat-1.6.1.tm
Not far obviously, it is in the same location as the other tcl libraries, but in a subdirectory tcl8
.
So question is : how do I tell tcl to look recursively in its TCL_LIBRARY variable or how do I pass multiple path in TCL_LIBRARY ?
I have tries many combinations of putting two directories in TCL_LIBRARY, all telling me that it fails at considering multiple path:
export TCL_LIBRARY="/snap/multigit/x21/usr/share/tcltk/tcl8.6;/snap/multigit/x21/usr/share/tcltk/tcl8.6/tcl8"
export TCL_LIBRARY="/snap/multigit/x21/usr/share/tcltk/tcl8.6:/snap/multigit/x21/usr/share/tcltk/tcl8.6/tcl8"
export TCL_LIBRARY="/snap/multigit/x21/usr/share/tcltk/tcl8.6,/snap/multigit/x21/usr/share/tcltk/tcl8.6/tcl8"
export TCL_LIBRARY="/snap/multigit/x21/usr/share/tcltk/tcl8.6 /snap/multigit/x21/usr/share/tcltk/tcl8.6/tcl8"
All leading to the same result:
osboxes@osboxes:/snap/multigit/x21/usr/share/tcltk$ gitk
application-specific initialization failed: Can't find a usable init.tcl in the following directories:
{/snap/multigit/x21/usr/share/tcltk/tcl8.6 /snap/multigit/x21/usr/share/tcltk/tcl8.6/tcl8} {/snap/multigit/x21/usr/share/tcltk/tcl8.6 /snap/multigit/x21/usr/share/tcltk/tcl8.6/tcl8.6} /usr/share/tcltk/tcl8.6 /snap/multigit/x21/usr/lib/tcl8.6 /snap/multigit/x21/lib/tcl8.6 /snap/multigit/x21/usr/library /snap/multigit/x21/library /snap/multigit/x21/tcl8.6.12/library /snap/multigit/tcl8.6.12/library
This probably means that Tcl wasn't installed properly.
Error in startup script: can't find package Tk
while executing
"package require Tk"
(file "/snap/multigit/x21/usr/bin/gitk" line 10)
Tcl supports both packages and modules. Packages are located by looking for pkgIndex.tcl files in subdirectories of the directories listed in the auto_path variable. The initial value of this variable can be influenced by the TCLLIBPATH environment variable.
Modules on the other hand are single files that must have a file name that must look like name-version.tm. Tcl looks for modules on the tcl::tm::path. This is a command rather than a variable. Use tcl::tm::path list
to view the list of directories. The initial value of the module path can also be modified by the use of environment variables. Tcl 8.6 will pick up TCL8_6_TM_PATH, TCL8_5_TM_PATH, TCL8_4_TM_PATH, TCL8_3_TM_PATH, TCL8_2_TM_PATH, TCL8_1_TM_PATH, and TCL8_0_TM_PATH. Modules are normally placed on the path for the lowest Tcl version with which they will work.