20

I'm attempting to load several modules for building a library on Linux but am told that the command 'module' doesn't exist. I've Googled around and discovered that the solution was to source a directory called "module" which I am unable to locate despite extensive searching.

I'm not quite sure what I should and any help would be appreciated (it might help to know that the makefile I'm working with uses csh while my default shell is bash). Thanks!

Sam
  • 433
  • 2
  • 4
  • 7

5 Answers5

25

I tried to reproduce it and it turns out that for me sourcing

source /etc/profile.d/modules.sh

in th .sh script helps for bash and similar. For csh and tcsh, you have to add

source /etc/profile.d/modules.csh

to the script. Note, that this line must come first and then the

module load foo

line.

Baedsch
  • 581
  • 5
  • 12
5

I got here as I was searching for ways to install multiple php versions in CentOS7 and https://blog.remirepo.net/post/2019/05/22/PHP-7.4-as-Software-Collection was one of the articles I tried to follow and encountered the same "module: command not found" issue.

Sourcing /etc/profile via command:

. /etc/profile

seems to make the "module load" work.

Credits to fadishei in https://forums.fedoraforum.org/showthread.php?262708-module-command-not-found

To make the version of php (e.g. php7.4) persist, append the following to file /etc/profile.d/custom.sh

source /etc/profile.d/modules.sh
module load php74

Reboot and run the php --version to cross-check that php 7.4 is the current version installed.

icasimpan
  • 1,253
  • 3
  • 16
  • 28
2

In my case, I was using zsh instead of the default bash shell.

After switching to bash and submitting the script, it worked out

vdi
  • 743
  • 10
  • 20
1

I think that you have to put this in your script to define the module command:

module () {
    eval `/usr/bin/modulecmd bash $*`
}
biegleux
  • 13,179
  • 11
  • 45
  • 52
bougui
  • 3,507
  • 4
  • 22
  • 27
0

This was working for me

#!/bin/bash -i // it will make this interactive
Striped
  • 2,544
  • 3
  • 25
  • 31
Deepak Mourya
  • 340
  • 2
  • 10