Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Use --prefix=/usr/local will cause the following problem: can't find package tclreadline.

105 views
Skip to first unread message

Hongyi Zhao

unread,
Jan 22, 2021, 8:20:30 PM1/22/21
to
On Ubuntu 20.10, I try to compile and install the latest git master version of tclreadline as shown below:

$ sudo apt-get build-dep -y tcl-tclreadline
$ git clone https://github.com/flightaware/tclreadline.git tclreadline.git
$ cd tclreadline.git
$ ./configure --prefix=/usr/local --libdir=/usr/local/lib/tcltk --enable-tclshrl --enable-wishrl
$ make
$ sudo make install

When I start tclsh, it will complain about the following problem:

$ tclsh
can't find package tclreadline
%


I also tried do the following `lappend auto_path /usr/local/lib' in my .tclshrc, but it can't fix the problem.
See the following for detailed info:

$ tail -5 .tclshrc
tclreadline::Loop
lappend auto_path /usr/local/lib
}

werner@X10DAi:~$ tclsh
can't find package tclreadline
%


Any hints for this problem will be highly appreciated.

Regards,
HY

Rich

unread,
Jan 23, 2021, 12:30:45 AM1/23/21
to
Hongyi Zhao <hongy...@gmail.com> wrote:
> On Ubuntu 20.10, I try to compile and install the latest git master
> version of tclreadline as shown below:
> $ ./configure --prefix=/usr/local --libdir=/usr/local/lib/tcltk
> --enable-tclshrl --enable-wishrl
>
> When I start tclsh, it will complain about the following problem:
>
> $ tclsh
> can't find package tclreadline
> %
>
>
> I also tried do the following `lappend auto_path /usr/local/lib' in
> my .tclshrc, but it can't fix the problem.

Check to see if this switch: --libdir=/usr/local/lib/tcltk placed your
output file into /usr/local/lib/tcltk.

If yes, then you need to put /usr/local/lib/tcltk into auto_path, not
/usr/local/lib.

Hongyi Zhao

unread,
Jan 23, 2021, 12:49:26 AM1/23/21
to
On Saturday, January 23, 2021 at 1:30:45 PM UTC+8, Rich wrote:
> Hongyi Zhao <hongy...@gmail.com> wrote:
> > On Ubuntu 20.10, I try to compile and install the latest git master
> > version of tclreadline as shown below:
> > $ ./configure --prefix=/usr/local --libdir=/usr/local/lib/tcltk
> > --enable-tclshrl --enable-wishrl
> >
> > When I start tclsh, it will complain about the following problem:
> >
> > $ tclsh
> > can't find package tclreadline
> > %
> >
> >
> > I also tried do the following `lappend auto_path /usr/local/lib' in
> > my .tclshrc, but it can't fix the problem.
> Check to see if this switch: --libdir=/usr/local/lib/tcltk placed your
> output file into /usr/local/lib/tcltk.

See the following:

$ ls -l /usr/local/lib/tcltk
total 60
-rwxr-xr-x 1 root root 53720 Jan 21 12:52 libtclreadline-2.3.8.so
-rwxr-xr-x 1 root root 1011 Jan 21 12:52 libtclreadline.la
lrwxrwxrwx 1 root root 23 Jan 21 12:52 libtclreadline.so -> libtclreadline-2.3.8.so


> If yes, then you need to put /usr/local/lib/tcltk into auto_path, not
> /usr/local/lib.

Tried with the above suggested setting but still fail to do the trick:

$ tail -5 .tclshrc
tclreadline::Loop
lappend auto_path /usr/local/lib/tcltk
}

# vim:set ft=tcl:

$ tclsh
can't find package tclreadline
%


Regards
HY

Eric

unread,
Jan 23, 2021, 5:10:05 AM1/23/21
to
On 2021-01-23, Hongyi Zhao <hongy...@gmail.com> wrote:
> On Saturday, January 23, 2021 at 1:30:45 PM UTC+8, Rich wrote:
8>< --------
>> Check to see if this switch: --libdir=/usr/local/lib/tcltk placed your
>> output file into /usr/local/lib/tcltk.
>
> See the following:
>
> $ ls -l /usr/local/lib/tcltk
> total 60
> -rwxr-xr-x 1 root root 53720 Jan 21 12:52 libtclreadline-2.3.8.so
> -rwxr-xr-x 1 root root 1011 Jan 21 12:52 libtclreadline.la
> lrwxrwxrwx 1 root root 23 Jan 21 12:52 libtclreadline.so -> libtclreadline-2.3.8.so
>
>
>> If yes, then you need to put /usr/local/lib/tcltk into auto_path, not
>> /usr/local/lib.
>
> Tried with the above suggested setting but still fail to do the trick:
>
> $ tail -5 .tclshrc
> tclreadline::Loop
> lappend auto_path /usr/local/lib/tcltk
> }

But the lappend has to be *before* the package require tclreadline !

Also check that there is a subdirectory of /usr/local/lib/tcltk called
tclreadlinesomething which contains 3 tcl scripts (names starting with
tclreadline) and a pkgIndex.tcl .

Eric
--
ms fnd in a lbry

Hongyi Zhao

unread,
Jan 23, 2021, 8:04:03 AM1/23/21
to
On Saturday, January 23, 2021 at 6:10:05 PM UTC+8, Eric wrote:
> On 2021-01-23, Hongyi Zhao <hongy...@gmail.com> wrote:
> > On Saturday, January 23, 2021 at 1:30:45 PM UTC+8, Rich wrote:
> 8>< --------
> >> Check to see if this switch: --libdir=/usr/local/lib/tcltk placed your
> >> output file into /usr/local/lib/tcltk.
> >
> > See the following:
> >
> > $ ls -l /usr/local/lib/tcltk
> > total 60
> > -rwxr-xr-x 1 root root 53720 Jan 21 12:52 libtclreadline-2.3.8.so
> > -rwxr-xr-x 1 root root 1011 Jan 21 12:52 libtclreadline.la
> > lrwxrwxrwx 1 root root 23 Jan 21 12:52 libtclreadline.so -> libtclreadline-2.3.8.so
> >
> >
> >> If yes, then you need to put /usr/local/lib/tcltk into auto_path, not
> >> /usr/local/lib.
> >
> > Tried with the above suggested setting but still fail to do the trick:
> >
> > $ tail -5 .tclshrc
> > tclreadline::Loop
> > lappend auto_path /usr/local/lib/tcltk
> > }
> But the lappend has to be *before* the package require tclreadline !

Thanks for pointing this out. Now I change the config to the following in ~/.tclshrc:

if {$tcl_interactive} {
lappend auto_path /usr/local/lib/tcltk
package require tclreadline

>
> Also check that there is a subdirectory of /usr/local/lib/tcltk called
> tclreadlinesomething which contains 3 tcl scripts (names starting with
> tclreadline) and a pkgIndex.tcl .

But I noted that the directories structure for my case are as following:

$ ls -l /usr/local/lib/tcltk/
total 60
-rwxr-xr-x 1 root root 53720 Jan 21 12:52 libtclreadline-2.3.8.so
-rwxr-xr-x 1 root root 1011 Jan 21 12:52 libtclreadline.la
lrwxrwxrwx 1 root root 23 Jan 21 12:52 libtclreadline.so -> libtclreadline-2.3.8.so

$ ls -l /usr/local/lib/tclreadline2.3.8/
total 256
-rw-r--r-- 1 root root 384 Jan 21 12:52 pkgIndex.tcl
-rw-r--r-- 1 root root 234612 Jan 21 12:52 tclreadlineCompleter.tcl
-rw-r--r-- 1 root root 1200 Jan 21 12:52 tclreadlineInit.tcl
-rw-r--r-- 1 root root 16010 Jan 21 12:52 tclreadlineSetup.tcl

With the above setting in ~/.tclshrc, I still meet the same error:

$ tclsh
can't find package tclreadline
%

OTOH, I also tried with the following setting in ~/.tclshrc:

if {$tcl_interactive} {
lappend auto_path /usr/local/lib
package require tclreadline

And the following error will be triggered:

$ tclsh
couldn't load file "script]]/libtclreadline.so": script]]/libtclreadline.so: cannot open shared object file: No such file or directory

js

unread,
Jan 23, 2021, 3:23:39 PM1/23/21
to
On 1/23/21 8:04 AM, Hongyi Zhao wrote:
> OTOH, I also tried with the following setting in ~/.tclshrc:
>
> if {$tcl_interactive} {
> lappend auto_path /usr/local/lib
> package require tclreadline
>
> And the following error will be triggered:
>
> $ tclsh
> couldn't load file "script]]/libtclreadline.so": script]]/libtclreadline.so: cannot open shared object file: No such file or directory
>


I haven't read the full thread here but a couple of points:
First, you seem to have multiple instances of the package tclreadline.
Second, you can add multiple paths to your auto_path:

% lappend auto_path /usr/local/lib/tcltk /usr/local/lib

Or try this in case it doesn't work or if you want to reach the one in
/usr/local/lib first:

% lappend auto_path /usr/local/lib /usr/local/lib/tcltk


Hongyi Zhao

unread,
Jan 23, 2021, 8:06:22 PM1/23/21
to
No, none of the above methods work. They all give the same error as below:

Rolf Ade

unread,
Jan 23, 2021, 8:33:46 PM1/23/21
to
Earlier in this thread you posted this directory listing:

$ ls -l /usr/local/lib/tclreadline2.3.8/
total 256
-rw-r--r-- 1 root root 384 Jan 21 12:52 pkgIndex.tcl
-rw-r--r-- 1 root root 234612 Jan 21 12:52 tclreadlineCompleter.tcl
-rw-r--r-- 1 root root 1200 Jan 21 12:52 tclreadlineInit.tcl
-rw-r--r-- 1 root root 16010 Jan 21 12:52 tclreadlineSetup.tcl

Could you please show us the content of this pkgIndex.tcl file.

js

unread,
Jan 23, 2021, 9:13:45 PM1/23/21
to
Well, it looks like you have the error message right there: I bet your
pkgindex.tcl file is broken or is non-standard. When it tries to load
the library, it finds "script]]/libtclreadline.so" as the file name and
not what you expect. The "script" may be a broken variable name or a
command name.

Hongyi Zhao

unread,
Jan 23, 2021, 9:42:47 PM1/23/21
to
$ cat /usr/local/lib/tclreadline2.3.8/pkgIndex.tcl
# FILE: pkgIndex.tcl.in
# $Id: b509c2d405b746ae3d2c718287b7d2adefb40cb6 $
# ---
# tclreadline -- gnu readline for tcl
# https://github.com/flightaware/tclreadline/
# Copyright (c) 1998 - 2014, Johannes Zellner <joha...@zellner.org>
# This software is copyright under the BSD license.
# ---

package ifneeded tclreadline 2.3.8 \
[list source [file join $dir tclreadlineInit.tcl]]



BTW, as I have posted at the beginning of this issue, the problem was caused by the following configuration:

./configure --prefix=/usr/local --libdir=/usr/local/lib/tcltk --enable-tclshrl --enable-wishrl

The above configuration is suggested by the author of the tclreadline package, see <https://github.com/flightaware/tclreadline/issues/33#issuecomment-763703823> for more detailed info.


OTOH, if I configure the source code package and revise the auto_path in the ~/.tclshrc as below, the problem will be fixed:

Configuration:

./configure --prefix=/usr/local --libdir=/usr/local/lib --enable-tclshrl --enable-wishrl

Revise the ~/.tclshrc:

Christian Gollwitzer

unread,
Jan 24, 2021, 2:18:57 AM1/24/21
to
Am 24.01.21 um 03:13 schrieb js:
To me this looks like a broken fragment of:

load [file dirname [info script]]/libtclreadline.so

If someone accidentally deletes the file dirname part, you'll get the
error.

Christian


Eric

unread,
Jan 24, 2021, 9:40:05 AM1/24/21
to
The actual line in tclreadlineInit.tcl is

foreach dirname {/usr/local/lib [file dirname [info script]]} {

followed by trying every value given to dirname until one works - if
none work, it exits with an error.

If the first (hard-coded) value works, everything is fine. However, the
list of values for dirname is actually

"/usr/local/lib" "[file" "dirname" "[info" "script]]"

because, inside the braces, the command substitutions don't happen!
Which perfectly explains the observed error.

The quoted line should be

foreach dirname [list /usr/local/lib [file dirname [info script]]] {

Even with this, I think avoiding the error will depend on the relationship
between the values of --prefix and --libdir , and some combinations will
not work.

Hongyi Zhao

unread,
Jan 24, 2021, 9:55:58 AM1/24/21
to
I try to replace the original line with the following two lines in tclreadlineInit.tcl:

#foreach dirname {/usr/local/lib [file dirname [info script]]} {
foreach dirname [list /usr/local/lib [file dirname [info script]]] {

Then I will meet the following error:

werner@X10DAi:~$ tclsh
missing close-brace: possible unbalanced brace in comment
%

If I completely replace the original line with your above line, it still can't fix the problem without adding the `lappend auto_path /usr/local/lib' into ~/.tclshrc:

werner@X10DAi:~$ tclsh
can't find package tclreadline
%


Eric

unread,
Jan 24, 2021, 10:22:05 AM1/24/21
to
On 2021-01-24, Hongyi Zhao <hongy...@gmail.com> wrote:
> On Sunday, January 24, 2021 at 10:40:05 PM UTC+8, Eric wrote:
>> On 2021-01-24, Christian Gollwitzer <auri...@gmx.de> wrote:
8>< --------
Unmatched braces in comments do cause problems, so completely replacing
the line rather than commenting it is *necessary*.

Needing the lappend is a separate issue. "package require" can only find
a package if its pkgIndex.tcl is in one of the directories in auto_path,
or in a directory below one of those.

Hongyi Zhao

unread,
Jan 24, 2021, 8:10:27 PM1/24/21
to
Why tcl language has such strict restrictions on commented code?

> Needing the lappend is a separate issue. "package require" can only find
> a package if its pkgIndex.tcl is in one of the directories in auto_path,
> or in a directory below one of those.

But I still can't figure out how to fix the problem when using the following configure option to compile the package:

js

unread,
Jan 25, 2021, 12:04:29 AM1/25/21
to
On 1/24/21 2:18 AM, Christian Gollwitzer wrote:
> Am 24.01.21 um 03:13 schrieb js:
>
> To me this looks like a broken fragment of:
>
>     load [file dirname [info script]]/libtclreadline.so
>
> If someone accidentally deletes the file dirname part, you'll get the
> error.
>

You are right; nice catch. Kudos to Eric too as I missed the curly
braces around the whole thing in the foreach command. Although I am
still not sure how he got to look inside the OP's tclreadlineInit.tcl
file to see it :-)

Christian Gollwitzer

unread,
Jan 25, 2021, 1:51:39 AM1/25/21
to
Am 25.01.21 um 06:04 schrieb js:
Probably by just looking here:

https://github.com/flightaware/tclreadline/blob/5c47f90c1839528e0d23cc386ad746bc4ee99f66/tclreadlineInit.tcl.in#L20


Christian

Eric

unread,
Jan 25, 2021, 5:40:05 AM1/25/21
to
Actually by looking at a downloaded copy of tclreadline - I was looking
at it a while back because rlwrap was behaving badly.

Ralf Fassel

unread,
Jan 25, 2021, 6:04:42 AM1/25/21
to
| But I noted that the directories structure for my case are as following:
>
| $ ls -l /usr/local/lib/tcltk/

| $ ls -l /usr/local/lib/tclreadline2.3.8/

YAFIYGI¹.

You need to put the directory where the pkgIndex file is to your
auto_path, not where library is. If all went went well, it will pick up
the library from /usr/local/lib/tcltk/.

But why do you use --libdir in your configure in addition to --prefix at
all? Go with only --prefix when compile the package (if at all, since
the default is usually the best to use) the directory with the pkgIndex
file to your auto_path.

HTH
R'
---
¹ http://catb.org/jargon/html/Y/YAFIYGI.html

Hongyi Zhao

unread,
Jan 25, 2021, 9:00:20 AM1/25/21
to
On Monday, January 25, 2021 at 7:04:42 PM UTC+8, Ralf Fassel wrote:
> | But I noted that the directories structure for my case are as following:
> >
> | $ ls -l /usr/local/lib/tcltk/
> | $ ls -l /usr/local/lib/tclreadline2.3.8/
>
> YAFIYGI¹.
>
> You need to put the directory where the pkgIndex file is to your
> auto_path, not where library is. If all went went well, it will pick up
> the library from /usr/local/lib/tcltk/.
>
> But why do you use --libdir in your configure in addition to --prefix at
> all?

This is a suggested configuration by the author of tclreadline, see <https://github.com/flightaware/tclreadline/issues/33#issuecomment-763703823> for more detailed info. But I think that it should be a typo by the author.
I've pointed the correct usage in the response comment, see <https://github.com/flightaware/tclreadline/issues/33#issuecomment-764138359> for more info. But till now, the developer doesn't give any reply.

> Go with only --prefix when compile the package

Completely agree with you. In fact, I use the following configuration for now, and it works smoothly:

./configure --prefix=/usr/local --enable-tclshrl --enable-wishrl

Eric

unread,
Jan 25, 2021, 10:54:47 AM1/25/21
to
On 2021-01-25, Hongyi Zhao <hongy...@gmail.com> wrote:
> On Sunday, January 24, 2021 at 11:22:05 PM UTC+8, Eric wrote:
8>< --------

>> Unmatched braces in comments do cause problems, so completely replacing
>> the line rather than commenting it is *necessary*.
>
> Why tcl language has such strict restrictions on commented code?

The actual rule for comments is:

If a hash character (“#”) appears at a point where Tcl is expecting
the first character of the first word of a command, then the hash
character and the characters that follow it, up through the next
newline, are treated as a comment and ignored. The comment character
only has significance when it appears at the beginning of a command.

(from http://www.tcl.tk/man/tcl/TclCmd/Tcl.htm#M30)

However, the "mismatched brace" is in a procedure definition. "proc" is
a built-in command which takes three arguments
the name of the procedure being defined
a list of the names of the arguments (possibly also defaults ...)
the body of the procedure.

The body is composed of a number of Tcl commands, so they must be grouped
to make a single argument (a "word") to "proc". Normally this is done
with braces, which are covered in another Tcl rule:

If the first character of a word is an open brace (“{”) and rule
[5] does not apply, then the word is terminated by the matching close
brace (“}”). Braces nest within the word: for each additional
open brace there must be an additional close brace (however, if an
open brace or close brace within the word is quoted with a backslash
then it is not counted in locating the matching close brace). No
substitutions are performed on the characters between the braces
except for backslash-newline substitutions described below, nor do
semi-colons, newlines, close brackets, or white space receive any
special interpretation. The word will consist of exactly the characters
between the outer braces, not including the braces themselves.

In other words, it won't notice the "#" but will notice the extra
opening brace.

And Tcl *is* its rules, there are only 12 of them. Any changes at the
rule level are likely to be both complex and controversial.

Eric

unread,
Jan 25, 2021, 10:54:48 AM1/25/21
to
On 2021-01-25, Hongyi Zhao <hongy...@gmail.com> wrote:
> On Sunday, January 24, 2021 at 11:22:05 PM UTC+8, Eric wrote:
8>< --------

> But I still can't figure out how to fix the problem when using the
> following configure option to compile the package:
>
> $ ./configure --prefix=/usr/local --libdir=/usr/local/lib/tcltk --enable-tclshrl --enable-wishrl
>

Neither can I, except to say "don't do that", regardless of what the
package maintainer says.

Making the build/install more robust would mean changes to the autoconf
and automake files and the variables that they use and set up. This is
probably not a simple change.

Just for the record, DESTDIR installs don't seem to work either.

Ralf Fassel

unread,
Jan 25, 2021, 11:41:22 AM1/25/21
to
* Hongyi Zhao <hongy...@gmail.com>
| > But why do you use --libdir in your configure in addition to --prefix at
| > all?
>
| This is a suggested configuration by the author of tclreadline, see
| <https://github.com/flightaware/tclreadline/issues/33#issuecomment-763703823>
| for more detailed info. But I think that it should be a typo by the author.

Note that if the installation process honors --libdir (i.e. put the
binary library somehwere else than the rest of the package), then the
generated pkgIndex file *needs* to reflect this altered location in the
'load' line.

From earlier postings in this thread it seemed to me that this was not
the case (i.e. this is an error in the package installation process),
since the pkgIndex file contained a more or less heuristic search for
the binary library which is plain wrong. The installation process
_knows_ where it had put the library, so it should note this exact
location in the pkgIndex.

Just my €0.02...
R'

Eric

unread,
Jan 25, 2021, 12:40:05 PM1/25/21
to
Except that the binary library is loaded in the Tcl script called by
pkgIndex.tcl (but that script is generated too, so you're still right -
possibly except for DESTDIR installs).

Hongyi Zhao

unread,
Jan 25, 2021, 8:05:55 PM1/25/21
to
Thank you very much for your in-depth and exhaustive explanation. Based on your notes, I find the 12 syntax and semantics rules of the Tcl language at <https://wiki.tcl-lang.org/page/Dodekalogue>.

Regards,
HY

Peter da Silva

unread,
Mar 30, 2021, 3:48:39 PM3/30/21
to
The problem is that they're installing tclreadline in a location his Tcl install isn't looking for packages. If they don't want to change that, there are some mitigating actions they can perform.
0 new messages