Tcl Source Code

View Ticket
Login
Ticket UUID: 2990516
Title: TM default paths do not search custom --libdir
Type: Bug Created on: 2010-04-21 17:36:57
Submitter: dgp Assigned to: dgp
Subsystem: 39. Package Manager Severity: Minor
Priority: 5 Medium Last modified: 2019-03-02 07:14:36
Status: Open Closed by: nobody
Resolution: None Closed on:
Version: None
Description:
The default paths set in [tcl::tm::path] are rooted at

[file dirname [info library]]

and

[file join [file dirname [file dirname [file normalize [info nameofexecutable]]]] lib]

The first wants to search near Tcl's script library which is
a sensible place TMs might have been installed.

The second is more problematic.  If one assumes [info nameofexecutable]
is meant to be tclsh in its normal installed location, then the construction
is attempting to produce the default value of $(libdir) for a Tcl install
which is the right place for any TM containing binary parts to get
installed.

However, Tcl permits customization of $(libdir).  One place this is
commonly used is on systems with both 32- and 64- bit collections
of binaries installed.  On such systems a 64-bit build of Tcl might
be customized to install into a $(libdir) like /usr/lib64 .  That path
can never be constructed from the TM defaults, because that
default hardcodes in the last element "lib".

By analogy, the older [tclPkgUnknown] package discovery
system potentially has the same problem, and has worked
around it via the variable ::tcl_pkgPath where the actual
configured value of $(libdir) gets stored and retrieved to
eventually find its way onto the $::auto_path .  It's a rather
ugly solution and I'm not recommending copying it.  Just
noting that this is not a new problem to solve.

I think the right place to find the value is in the result
returned by the command

[tcl::pkgconfig get libdir,runtime]

This, of course, means we will have a renewed interest
in making that command actually work.
User Comments:
dgp added on 2010-04-22 00:44:35:
Forgot to explicitly mention it, but of course Tcl
is a library that gets embedded in many programs
other than tclsh, and those programs need not
be installed in any particular location relative to
Tcl's $(libdir), so the second default root is not
reliable at all.  Perhaps defensible as one of many attempts
to throw something at the wall and see what sticks,
but if [tcl::pkgconfig] is doing its job and telling us
directly where Tcl was configured to be installed, I think
we would be better off using direct reporting over guesses.

aspect added on 2019-03-02 07:14:36:
The second default could be described as downright dangerous for embedding 
programs and starpacks.  It's also surprising if [info nameofexe] happens to 
be a symlink.

What would it take to fix this?  Is [tcl::pkgconfig get libdir,runtime] 
still unreliable for this purpose?

(anecdotally, I don't see any binary .tm's in the wild so I'm tempted to 
argue for removing the second default altogether ..)