Bug 1575479

Summary: row 58: export: _moduleraw is not a function
Product: [Fedora] Fedora Reporter: Marco Motta <marco.motta>
Component: environment-modulesAssignee: Jan Synacek <jsynacek>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 28CC: jsynacek, orion, praiskup, xavier.delaruelle
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: environment-modules-4.1.3-1.fc28 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-06-26 17:34:20 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
init/export _moduleraw if stderr attached to term none

Description Marco Motta 2018-05-07 04:42:30 UTC
Description of problem:
An error message is displayed opening a new terminal as root: _moduleraw is not a function

Version-Release number of selected component (if applicable):
environment-modules-4.1.2-1.fc28.x86_64

How reproducible:

$ echo "su - -c ls 2>/tmp/test" >/tmp/test.sh; chmod +x /tmp/test.sh; xfce4-terminal -x /tmp/test.sh; cat /tmp/test


Steps to Reproduce:

Open gnome-terminal, and type
$ echo "su - -c ls 2>/tmp/test" >/tmp/test.sh; chmod +x /tmp/test.sh; xfce4-terminal -x /tmp/test.sh; cat /tmp/test

Actual results:
Password: 
/usr/share/Modules/init/bash: riga 58: export: _moduleraw: non è una funzione


Expected results:
Password: 


Additional info:

Comment 1 Andrea 2018-05-07 15:17:53 UTC
I have the same error message when I use mc to browse inside archives (rpm, zip).

I've opened a bug for mc, but it seems it is not caused by mc itself.
Moreover it does not happen with all users.

I am using environment-modules-4.1.2-1.fc28.x86_64 and all the latest packages as of now.

https://bugzilla.redhat.com/show_bug.cgi?id=1575518

Comment 2 Tomasz Kłoczko 2018-05-07 15:23:24 UTC
This is not bug in mc.

Comment 3 Marco Motta 2018-05-07 15:26:57 UTC
Surely the problem is of environment-modules, because the error message is on line 58 of /usr/share/Modules/init/bash, and:

$ dnf provides /usr/share/Modules/init/bash
Sincronizzazione cache non riuscita per il repo 'ksplice-uptrack', disabilitazione in corso.
Ultima verifica della scadenza dei metadati: 22:57:39 fa il dom 06 mag 2018 18:21:59 CEST.
environment-modules-4.1.2-1.fc28.x86_64 : Provides dynamic modification of a
                                        : user's environment
Repo         : @System
Corrispondenza trovata in:
Nome file   : /usr/share/Modules/init/bash

environment-modules-4.1.2-1.fc28.x86_64 : Provides dynamic modification of a
                                        : user's environment
Repo         : fedora
Corrispondenza trovata in:
Nome file   : /usr/share/Modules/init/bash


I think this is related to work with this bug: https://bugzilla.redhat.com/show_bug.cgi?id=1575479

Comment 4 Marco Motta 2018-05-07 15:28:59 UTC
Strange, I upgraded to Fedora 28, and the bug is back:

$ (echo "∅"; echo "∞"; echo "∅") | sort | uniq
∅
[marco@localhost ~]$

Comment 5 Andrea 2018-05-07 15:30:38 UTC
It has something to do with the current environment.

Happens in GNOME: xterm, Konsole and GNOME terminal

but not in a linux console outside GNOME.

Comment 6 Andrea 2018-05-07 15:39:20 UTC
And there is indeed a pattern here

From GNOME

andrea@bomba:~/projects/cvs/poolviewer$ env | grep BASH_FUNC
BASH_FUNC_module%%=() {  unset _mlre _mlIFS _mlshdbg;
BASH_FUNC_switchml%%=() {  typeset swfound=1;
BASH_FUNC_scl%%=() {  if [ "$1" = "load" -o "$1" = "unload" ]; then


from a console

BASH_FUNC_module%%=() {  _moduleraw "$@" 2>&1
BASH_FUNC_switchml%%=() {  typeset swfound=1;
BASH_FUNC_scl%%=() {  if [ "$1" = "load" -o "$1" = "unload" ]; then
BASH_FUNC__moduleraw%%=() {  unset _mlre _mlIFS _mlshdbg;


And you can see the 4th is missing in GNOME.

What does this all mean?

Comment 7 Andrea 2018-05-07 18:02:00 UTC
I fixed it by resetting the bash templates (rc and profile).

My home folder is really old and I guess something in bash has changed, so the old bashrc had become incompatible over time.

Comment 8 Marco Motta 2018-05-07 18:29:56 UTC
(In reply to Marco Motta from comment #4)
> Strange, I upgraded to Fedora 28, and the bug is back:
> 
> $ (echo "∅"; echo "∞"; echo "∅") | sort | uniq
> ∅
> [marco@localhost ~]$

Excuse me, but I send comment #4 to the wrong bug.

Comment 9 Xavier Delaruelle 2018-05-19 09:57:16 UTC
I was not able to reproduce the issue with the guide lines provided above. However this issue can easily be reproduced with the following sequence:

$ cat test.sh
unset module
unset moduleraw
source /usr/share/Modules/init/bash
$ bash test.sh 2>errlog; cat errlog
/usr/share/Modules/init/bash: line 48: export: _moduleraw: not a function

Issue is due to the test controlling the creation of the _moduleraw shell function. In modulecmd.tcl this test checks stderr whereas in init scripts test checks stdout. So if stderr is not detected as attached to a terminal but stdout is, modulecmd.tcl autoinit command does not produce code for the _moduleraw shell function but afterward shell init script still tries to export this non-existent function.

Comment 10 Xavier Delaruelle 2018-05-19 09:59:28 UTC
Created attachment 1438875 [details]
init/export _moduleraw if stderr attached to term

Attached patch fixes the issue. I can be applied over current v4.1.2 package and will be part of the next bugfix release (v4.1.3)

Comment 11 Xavier Delaruelle 2018-06-18 04:46:08 UTC
Fixed in upstream bugfix release v4.1.3

Comment 12 Fedora Update System 2018-06-18 11:03:59 UTC
environment-modules-4.1.3-1.fc28 has been submitted as an update to Fedora 28. https://bodhi.fedoraproject.org/updates/FEDORA-2018-082f52eeac

Comment 13 Fedora Update System 2018-06-18 17:08:42 UTC
environment-modules-4.1.3-1.fc28 has been pushed to the Fedora 28 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2018-082f52eeac

Comment 14 Fedora Update System 2018-06-26 17:34:20 UTC
environment-modules-4.1.3-1.fc28 has been pushed to the Fedora 28 stable repository. If problems still persist, please make note of it in this bug report.