3

Today I upgraded from Ubuntu 16.04 to 18.04 to 20.04

After Login I get the error

enter image description here

Error found when loading /etc/profile:

/etc/profile.d/modules.sh: line 6: usr/share/modules/init/sh: no such file or dicrectory

As a result the session will not be configured correctly.
You should fix the problem as soon as feasible

The code in etc/profile.d/modules.sh is:

shell=$(/usr/bin/basename $(/bin/ps -p $$ -ocomm=))

if [ -f /usr/share/modules/init/$shell ]; then
   . /usr/share/modules/init/$shell
else
   . /usr/share/modules/init/sh
fi

But

The path /usr/share/modules does not exist

How to adapt the script?

Thorsten Niehues
  • 1,277
  • 5
  • 17
  • 32

3 Answers3

2

I did a fresh install of ubuntu 20.04 on VirtualBox and noticed that the file etc/profile.d/modules.sh does not exist in a fresh installation.

So I renamed the file etc/profile.d/modules.sh to etc/profile.d/modules.sh.ubuntu16.04 in order not to be executed
(pattern /etc/profile.d/*.sh within the /etc/profile does not match any more)

After that the error message does not appear any more.

Thorsten Niehues
  • 1,277
  • 5
  • 17
  • 32
0

Delete it

The /etc/profile.d/modules.sh script is a remnant of previous Ubuntu LTS releases. It may safely be deleted.

$ sudo rm /etc/profile.d/modules.sh

After doing so, the error message will no longer appear.

Serge Stroobandt
  • 5,268
  • 1
  • 48
  • 59
0

On my system, using

dpkg -S /etc/profile.d/modules.sh

showed that file /etc/profile.d/modules.sh belongs to apt package environment-modules.

Using commands to show dependencies on environment-modules, such as

apt-cache rdepends --installed environment-modules
apt -s remove environment-modules
aptitude why environment-modules

showed that environment-modules was actually neither needed by other packages nor even (fully) installed on my system.

Using commands to show historical apt package log data, such as

ls -rt /var/log/dpkg.log* | xargs zgrep install | less
ls -rt /var/log/dpkg.log* | xargs zgrep install | grep environment-modules

showed that, from all log entries mentioning environment-modules, most recently, environment-modules was only "half-installed".

And indeed, using dpkg -l | grep ^rc (see 1, 2) showed that environment-modules was apt-removed but not yet completely apt-purged.

I therefore concluded that it is safe to remove and purge the environment-modules package using

apt remove environment-modules
apt purge environment-modules

This purge did indeed remove file /etc/profile.d/modules.sh from my system. Since then, I got rid of aforementioned error message.

Abdull
  • 502