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

How to Extend the Tcl Path System-wide?

94 views
Skip to first unread message

J Leslie Turriff

unread,
Sep 22, 2018, 6:44:39 PM9/22/18
to
I'm new to Tcl, so this might be an old issue.
On my Linux system, OpenSuSE, Tcl is installed as follows:
$ tree -d /usr/lib64/tcl
/usr/lib64/tcl
├── expect5.45.3
├── itcl4.1.0
├── sqlite3.20.0
├── tcl8
│   ├── 8.4
│   │   └── platform
│   ├── 8.5
│   └── 8.6
│   └── tdbc
├── tcl8.6
│   ├── encoding
│   ├── http1.0
│   ├── msgs
│   └── opt0.4
├── tdbc1.0.5
├── tdbcmysql1.0.5
├── tdbcodbc1.0.5
├── tdbcpostgres1.0.5
├── thread2.8.1
└── tk8.6
├── demos
│   └── images
├── images
├── msgs
└── ttk

and tcl_pkgPath shows
$ tclsh
% set tcl_pkgPath
/usr/lib64/tcl /usr/share/tcl

I want to add /usr/local/lib64/tcl (which resides in a separate
partition) to the path on a system-wide basis so that system upgrades don't
interact with locally installed Tcl code, and so that each user on the
system doesn't have tweak the Tcl path.
What's the best way to accomplish this?--
JLT

heinrichmartin

unread,
Sep 23, 2018, 8:57:44 AM9/23/18
to
On Sunday, September 23, 2018 at 12:44:39 AM UTC+2, J Leslie Turriff wrote:
> $ tclsh
> % set tcl_pkgPath
> /usr/lib64/tcl /usr/share/tcl
>
> I want to add /usr/local/lib64/tcl (which resides in a separate
> partition) to the path on a system-wide basis so that system upgrades don't
> interact with locally installed Tcl code,

Not so sure about this constraint (not even whether I fully understand it), but assuming the best for my suggestion below.

> and so that each user on the
> system doesn't have tweak the Tcl path.
> What's the best way to accomplish this?--

While I haven't found a global rc-file for tclsh, you could set TCLLIBPATH in the shell's rc-file.

"Note: tcl_pkgPath is not intended to be modified by the application. Its value is added to auto_path at startup; changes to tcl_pkgPath are not reflected in auto_path. If you want Tcl to search additional directories for packages you should add the names of those directories to auto_path, not tcl_pkgPath." [1]

Note that tclsh (called in a shell) is just one possibility to initialize a Tcl interpreter, e.g. expect has $exp_library/expect.rc.

HTH
Martin

[1] http://tcl.tk/man/tcl8.6/TclCmd/tclvars.htm#M23

J Leslie Turriff

unread,
Sep 23, 2018, 9:33:19 AM9/23/18
to
heinrichmartin wrote:
> On Sunday, September 23, 2018 at 12:44:39 AM UTC+2, J Leslie Turriff
> wrote:
>> $ tclsh
>> % set tcl_pkgPath
>> /usr/lib64/tcl /usr/share/tcl
>>
>> I want to add /usr/local/lib64/tcl (which resides in a separate
>> partition) to the path on a system-wide basis so that system upgrades
>> don't interact with locally installed Tcl code,
>
> Not so sure about this constraint (not even whether I fully understand
> it), but assuming the best for my suggestion below.
>
>> and so that each user on the
>> system doesn't have tweak the Tcl path.
>> What's the best way to accomplish this?--
>
> While I haven't found a global rc-file for tclsh, you could set TCLLIBPATH
> in the shell's rc-file.
Okay, but that means that every individual user would have to modify
their .bashrc, right?
>
> "Note: tcl_pkgPath is not intended to be modified by the application. Its
> value is added to auto_path at startup; changes to tcl_pkgPath are not
> reflected in auto_path. If you want Tcl to search additional directories
> for packages you should add the names of those directories to auto_path,
> not tcl_pkgPath." [1]
Yeah; it's difficult for me to see which of these have priority over
others, which shouldn't be touched, etc.
>
> Note that tclsh (called in a shell) is just one possibility to initialize
> a Tcl interpreter, e.g. expect has $exp_library/expect.rc.
Does tclsh have an equivalent to the bash shell's .bashrc?
>
> [1] http://tcl.tk/man/tcl8.6/TclCmd/tclvars.htm#M23

--
JLT

heinrichmartin

unread,
Sep 23, 2018, 9:41:31 AM9/23/18
to
On Sunday, September 23, 2018 at 3:33:19 PM UTC+2, J Leslie Turriff wrote:
> heinrichmartin wrote:
> > While I haven't found a global rc-file for tclsh, you could set TCLLIBPATH
> > in the shell's rc-file.
> Okay, but that means that every individual user would have to modify
> their .bashrc, right?

Not in general, I have a global location, too. This depends on your setup / OS / distribution. (Don't know whether this is defined for *NIX...)

> >
> > "Note: tcl_pkgPath is not intended to be modified by the application. Its
> > value is added to auto_path at startup; changes to tcl_pkgPath are not
> > reflected in auto_path. If you want Tcl to search additional directories
> > for packages you should add the names of those directories to auto_path,
> > not tcl_pkgPath." [1]
> Yeah; it's difficult for me to see which of these have priority over
> others, which shouldn't be touched, etc.

I'm using TCLLIBPATH successfully to include packages from a dev workspace.

Rich

unread,
Sep 23, 2018, 4:01:08 PM9/23/18
to
J Leslie Turriff <jltu...@mail.com> wrote:
> heinrichmartin wrote:
>> On Sunday, September 23, 2018 at 12:44:39 AM UTC+2, J Leslie Turriff
>> wrote:
>>> I want to add /usr/local/lib64/tcl (which resides in a separate
>>> partition) to the path on a system-wide basis so that system upgrades
>>> don't interact with locally installed Tcl code,
>>
>> While I haven't found a global rc-file for tclsh, you could set TCLLIBPATH
>> in the shell's rc-file.
> Okay, but that means that every individual user would have to modify
> their .bashrc, right?

Not if the environment variable were defined in the global system-wide
shell rc file.

Roger Oberholtzer

unread,
Sep 24, 2018, 4:44:37 AM9/24/18
to
On Sunday, September 23, 2018 at 3:33:19 PM UTC+2, J Leslie Turriff wrote:

> >> and so that each user on the
> >> system doesn't have tweak the Tcl path.
> >> What's the best way to accomplish this?--

Add a file to /etc/profile.d/ with the environment changes you want to make. Then everyone gets that in their environment.


J Leslie Turriff

unread,
Sep 24, 2018, 7:07:51 PM9/24/18
to
Ah, thanks; I knew there was some such way of doing it, but couldn't
remember just what it was.
JLT

J Leslie Turriff

unread,
Sep 24, 2018, 7:08:40 PM9/24/18
to
Okay, TCLLIBPATH. I'll give that a try. Thanks.
JLT

heinrichmartin

unread,
Sep 25, 2018, 3:22:00 AM9/25/18
to
On Tuesday, September 25, 2018 at 1:08:40 AM UTC+2, J Leslie Turriff wrote:
> > I'm using TCLLIBPATH successfully to include packages from a dev
> > workspace.
> Okay, TCLLIBPATH. I'll give that a try. Thanks.

One more thing: remember that packages are found one level deeper, i.e. $TCLLIBPATH/*/pkgIndex.tcl ... look at your $auto_path and compare with existing locations.

Bezoar

unread,
Dec 1, 2018, 1:53:12 PM12/1/18
to
On linux systems ( in general ), the profile file in /etc ( i.e. /etc/profile)is sourced by users .bashrc or other sh compatable shells to do system wide setup. The profile is a script itself and can source addtional files in /etc/profile.d. So the idea is either update /etc/profile directly or create your own script that will be sourced by /etc/profile. As root update the PATH variable in that file or in a sub file sourced by profile using 'export PATH=${PATH}:<path to tcl binaries>'. Note for this command to work correctly PATH needs to be set already. So do this if you are not sure

if [ -z ${PATH} ]; then
export PATH=<path to tcl binaries>;
else
export PATH=${PATH}:<path to tcl binaries>
fi

It is important that you insert your tcl path ahead of the directory in the path that has the system installed tcl. So depending on your system you may have to do more manipulation of the path to get it in the correct place.

Bezoar

0 new messages