Improper reference to modulecmd in bash_completion script

Bug #1056014 reported by Alexey Brodkin
40
This bug affects 8 people
Affects Status Importance Assigned to Milestone
modules (Debian)
Fix Released
Unknown
modules (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Bash completion doesn't work for this package.
And this is because path specified to "modulecmd" binary doesn't match real "modulecmd" location.
========
$ which modulecmd
/usr/bin/modulecmd
========

an extract of bash_completion script:
========
$ cat /etc/bash_completion.d/modules
#
# Bash commandline completion (bash 3.0 and above) for Modules 3.2.9
#
_module_avail() {
 /usr/share/modules/3.2.9/bin/modulecmd bash -t avail 2>&1 | sed '
  /:$/d;
  /:ERROR:/d;
  s#^\(.*\)/\(.\+\)(default)#\1\n\1\/\2#;
  s#/(default)##g;
  s#/*$##g;'
}
...
========

As a consequence execution of "_module_avail" gives an error:
========
$ _module_avail
bash: /usr/share/modules/3.2.9/bin/modulecmd: No such file or directory
========

Attached is a simple patch that fixes this issue.

My system is:
$lsb_release -rd
Description: Ubuntu 12.04.1 LTS
Release: 12.04

Though this package is only available for Quantal so installed it from corresponding .deb
$ apt-cache policy environment-modules
environment-modules:
  Installed: 3.2.9c-2
  Candidate: 3.2.9c-2
  Version table:
 *** 3.2.9c-2 0
        100 /var/lib/dpkg/status

BTW it seems like the same issue is present in Debian package http://packages.debian.org/unstable/main/environment-modules

Tags: patch
Revision history for this message
Alexey Brodkin (alexey-brodkin) wrote :
Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "modules.diff" of this bug report has been identified as being a patch. The ubuntu-reviewers team has been subscribed to the bug report so that they can review the patch. In the event that this is in fact not a patch you can resolve this situation by removing the tag 'patch' from the bug report and editing the attachment so that it is not flagged as a patch. Additionally, if you are member of the ubuntu-reviewers team please also unsubscribe the team from this bug report.

[This is an automated message performed by a Launchpad user owned by Brian Murray. Please contact him regarding any issues with the action taken in this bug report.]

tags: added: patch
Revision history for this message
Alexey Brodkin (alexey-brodkin) wrote :

Attached is a modified patch from "modules_3.2.9c-2.debian.tar.gz" that produces expected "bash_completion" script

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in modules (Ubuntu):
status: New → Confirmed
Changed in modules (Debian):
status: Unknown → New
Changed in modules (Debian):
status: New → Fix Released
Revision history for this message
Bradley M. Froehle (brad-froehle) wrote :

Fixed in 3.2.9c-3 (https://launchpad.net/ubuntu/+source/modules/3.2.9c-3) which is in raring now.

Revision history for this message
Alexey Brodkin (alexey-brodkin) wrote :

Fixed bug was re-introduced in 3.2.10-1 (the one from Ubuntu 13.04).
It could be seen from this diff: http://launchpadlibrarian.net/129638318/modules_3.2.9c-3_3.2.10-1.diff.gz
===========
  _module_avail() {
 -@VERSIONING@ @BASEPREFIX@/Modules/@VERSION@/bin/modulecmd bash -t avail 2>&1 | sed '
 -@NOTVERSIONING@ @bindir@/modulecmd bash -t avail 2>&1 | sed '
-+@VERSIONING@ modulecmd bash -t avail 2>&1 | sed '
++@VERSIONING@ /usr/share/modules/@VERSION@/bin/modulecmd bash -t avail 2>&1 | sed '
===========

Please fix this once again.

Revision history for this message
Gabriel A. Devenyi (gadevenyi) wrote :

How are all these launchpad bugs open for so long? The fix is attached!

Revision history for this message
Benedikt Heine (bebehei) wrote :

Dear package-maintainer could you please fix this? This is in 14.04 and 15.04, too!

Revision history for this message
Stefan Fleischmann (sfleischmann) wrote :

Still present in 16.04 LTS. Lmod http://packages.ubuntu.com/xenial/lmod might be a good alternative.

Revision history for this message
Jonathan Michalon (jmichalon) wrote :

Yeah, very annoying. For now in my scripts I fix it the ugly way:
  sed -i 5s-share/modules/3.2.10-- /etc/bash_completion.d/modules

Revision history for this message
Xavier Delaruelle (xdelaruelle) wrote :

This issue is fixed in Ubuntu 18.04, which is shipped with a new release of Modules.

# module -V
Modules Release 4.1.1 (2018-02-17)
# which modulecmd
/usr/bin/modulecmd
# type _module_avail
_module_avail is a function
_module_avail ()
{
    module avail -t 2>&1 | sed '
        /^-\+/d; /^\s*$/d;
        /->.*$/d;
        /:$/d;
        /:ERROR:/d;
        s#^\(.*\)/\(.\+\)(.*default.*)#\1\n\1\/\2#;
        s#(.*)$##g;
        s#\s*$##g;
        s#/*$##g;'
}
# _module_avail
dot
module-git
module-info
modules
null
use.own
dot
module-git
module-info
modules
null
use.own

Changed in modules (Ubuntu):
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.