Skip to content

source Tcl command encoding error on clock command #627

Description

@MathieuCAISSA

Describe the bug

The source command executed by a module does not behave the same way as standard TCL on our clusters (HPC environment).
This reproducer uses the clock scan command as an example, which sources /usr/share/tcl8.6/clock.tcl.

We tested this behavior across different configurations using containers, and the table below summarizes our findings:

+------------------------+----------------+--------+
| Environment / Method   | Execution Type | Status |
+========================+================+========+
| Everywhere             | TCL Command    |   ✅   |
+------------------------+----------------+--------+
| Our cluster            | Module-5.6     |   ❌   | 
+------------------------+----------------+--------+
| Personal PC            | Module-5.6     |   ✅   |
+------------------------+----------------+--------+
| Ubuntu 26 Container    | Module-5.6     |   ✅   |
+------------------------+----------------+--------+
| AlmaLinux 8 Container  | Module-4.5     |   ✅   |
+------------------------+----------------+--------+
| AlmaLinux 9 Container  | Module-5.3     |   ✅   |
+------------------------+----------------+--------+
| AlmaLinux 8 Container  | Module-5.6     |   ✅   |
+------------------------+----------------+--------+
| AlmaLinux 9 Container  | Module-5.6     |   ✅   |
+------------------------+----------------+--------+

The issue is only present on our cluster.

To Reproduce

With a module on the cluster, -encoding utf-8 is added between source and /usr/share/tcl8.6/clock.tcl:

$ cat modulefile/repro/sourceTCL
#%Module5.0
puts stderr [clock scan "2026-05-04" -format %Y-%m-%d]

$ module use ${PWD}/modulefile
$ module show repro/sourceTCL
Module ERROR: wrong # args: should be "source filename"
      invoked from within
  "source -encoding utf-8 [file join $TclLibDir clock.tcl]"
      (procedure "::tcl::clock::scan" line 3)
      invoked from within
  "clock scan "2026-05-04" -format %Y-%m-%d"
      (file "~/modulefile/repro/sourceTCL" line 2)
  Please contact <root@localhost>

Expected behavior

In standard TCL commands, it works normally:

$ tclsh
% puts [clock scan "2026-05-04" -format %Y-%m-%d]
1777845600

Error and debugging information

With the -DD module option on the command that returns the error, we get:

[...]
DEBUG [#1:load:repro/sourceTCL] evaluateModulefile: sourceModfileCmd __modfile_load_1_1 -encoding utf-8 /usr/share/tcl8.6/clock.tcl
DEBUG [#1:load:repro/sourceTCL] execute-modulefile: renderModulefileEvalError __modfile_load_1_1 load ~/modulefile/repro/sourceTCL 1 {wrong # args: should be "sourceModfileCmd itrp filename"}
[...]

Modules version and configuration

$ module --version
Modules Release 5.6.0 (2025-07-31)

Additional information

Our cluster use RedHat 8.10 OS
Our TCL version is tcl-8.6.8-2.el8.x86_64

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions