Skip to content

Modules does not properly remove path starting with ~ when unloading a module #597

Closed

Description

@x3x7

Describe the bug

In Fedora 42 from WSL2 (Windows Subsystem for Linux 2) the modules do not properly remove the path when unloading a module

To Reproduce

Steps to reproduce the behavior:

Create a module with prepend-path and load it.
When unloading it the path element still remains.

This happens with bash as well as tcsh and even with very simple, empty PATH.

Expected behavior

The added path to be removed.

Modules version and configuration

environment-modules-5.5.0-3.fc42

Activity

  1. changed the title [-]In fedora 42 from WSL the modules do not properly remove the path when unloading a module[/-] [+]In Fedora 42 from WSL the modules do not properly remove the path when unloading a module[/+] on Oct 24, 2025
  2. xdelaruelle commented on Oct 26, 2025

    @xdelaruelle
    Collaborator

    I am using a Fedora 42 on my laptop and I cannot reproduce the issue you describe:

    $ module -V
    Modules Release 5.5.0 (2024-11-11)
    $ module list
    No Modulefiles Currently Loaded.
    $ cat ./prepend-test 
    #%Module
    prepend-path PATH /path/to/dir
    $ echo $PATH
    /usr/bin:/usr/share/Modules/bin:/usr/local/bin
    $ module load ./prepend-test 
    $ echo $PATH
    /path/to/dir:/usr/bin:/usr/share/Modules/bin:/usr/local/bin
    $ module unload ./prepend-test
    $ module list
    No Modulefiles Currently Loaded.
    $ echo $PATH
    /usr/bin:/usr/share/Modules/bin:/usr/local/bin

    Could you please run the same command sequence in your Fedora WSL environment and report here the output you obtain. Providing the content of your modulefile will help to understand what is going on.

  3. x3x7 commented on Oct 27, 2025

    @x3x7
    Author

    Indeed, the modules work with regular paths. I have abused it by a statement like below

    prepend-path PATH ~/tools/arm/bin

    and it almost worked by placing the proper expanded path at the front. The problematic issue is the ~ and it should not be used since the path can't be cleared on module cleanup. This is therefore not a bug but misuse from my part.

    Another issue is that the WSL path can be a nightmare, example in my case is bellow

    /home/user/.local/bin:/home/user/bin:/usr/share/Modules/bin:/usr/lib64/ccache:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/Program Files/PowerShell/7:/mnt/c/Program Files/Python313/Scripts/:/mnt/c/Program Files/Python313/:/mnt/c/windows/system32:/mnt/c/windows:/mnt/c/windows/System32/Wbem:/mnt/c/windows/System32/WindowsPowerShell/v1.0/:/mnt/c/windows/System32/OpenSSH/:/mnt/c/Program Files/WindowsPowerShell/Scripts:/mnt/c/Program Files (x86)/STMicroelectronics/STM32 ST-LINK Utility/ST-LINK Utility:/mnt/c/Program Files/dotnet/:/mnt/c/Program Files/usbipd-win/:/mnt/c/Program Files/Git/cmd:/mnt/c/Program Files/CMake/bin:/mnt/c/Program Files/PuTTY/:/mnt/c/Program Files/PowerShell/7/:/mnt/c/Users/ett15530/.cargo/bin:/mnt/c/Users/ett15530/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/ett15530/AppData/Local/Programs/Microsoft VS Code/bin

  4. xdelaruelle commented on Oct 28, 2025

    @xdelaruelle
    Collaborator

    Modules does not resolve ~ but the shell, when evaluating output produced by Modules, does. So when unloading the modulefile, as the shell has transformed the path entry, Modules is not able to find it to remove it from the path variable.

    If you want to use paths containing the ~ character and as you are using Tcl9, I suggest to use the following code:

    prepend-path PATH [file tildeexpand ~/tools/arm/bin]
  5. changed the title [-]In Fedora 42 from WSL the modules do not properly remove the path when unloading a module[/-] [+]Modules do not properly remove path starting with `~` when unloading a module[/+] on Oct 28, 2025
  6. changed the title [-]Modules do not properly remove path starting with `~` when unloading a module[/-] [+]Modules does not properly remove path starting with `~` when unloading a module[/+] on Oct 28, 2025
  7. xdelaruelle commented on Oct 28, 2025

    @xdelaruelle
    Collaborator

    I will update the man page to mention that path element provided to prepend-path command are not transformed but shell may interpret it.

  8. added this to the 5.6.1 milestone on Oct 28, 2025
  9. added a commit that references this issue on Nov 11, 2025
    6860bde
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