Output displays "sh: error importing function definition for `which'" on RHEL8
search cancel

Output displays "sh: error importing function definition for `which'" on RHEL8

book

Article ID: 251512

calendar_today

Updated On:

Products

CA Automic Applications Manager (AM)

Issue/Introduction

When running the default TEST_JOB or other Jobs on Redhat Enterprise Linux 8 following errors are seen in the job out file. This does not impact the completion of the job.

End of parameter file
job pid 11111

End of parameter file
job pid 12345

Executing PREFIX
PREFIX script echo(s) below:
application: APPWORX net_connect:  command: test_module
No changes made because of application string!
Exiting Prefix Script
starting at 
complete at 
awprint PRINT -j 123456789.00 -n b.123456789.00 -d /u01/appworxtest/out
return code = 0
*****************************
* Finished  with status FINISHED (FINISHED)
sh: error importing function definition for `which'
Executing PREFIX
Standalone PREFIX script echo(s) below:
application: APPWORX net_connect:  command: test_module
No changes made because of application string!
Exiting Prefix Script
sh: which: line 1: syntax error: unexpected end of file
sh: error importing function definition for `which'
sh: which: line 1: syntax error: unexpected end of file
sh: error importing function definition for `which'
sh: which: line 1: syntax error: unexpected end of file
sh: error importing function definition for `which'
starting at 
complete at 
sh: which: line 1: syntax error: unexpected end of file
sh: error importing function definition for `which'
sh: which: line 1: syntax error: unexpected end of file
sh: error importing function definition for `which'
awprint PRINT -j 123456789.00 -n b.123456789.00 -d /u01/appworxtest/out
return code = 0
Executing COMPLETION
*****************************
* Finished  with status FINISHED (FINISHED)

Environment

Release : 9.3 and 9.4

Cause

This is caused by a change made to the system file /etc/profile.d/which2.sh on RHEL 8.

Starting in RHEL 8 the which2.sh sets bash functions for 'which'

The error occurs due to installing the one or both the following packages:
scl-utils 
environment-modules 

Resolution

The following can be used as work around.

Add the following to the $AW_HOME/site/sosite file. Once added, the Applications Manager process will need to be stopped, and sosite needs to be run before before restarting for the change to take effect.

unset ${which_opt} which

unset which_declare

Additionally, the following single command can be used:

unset -f $(env | grep -oP "^BASH_FUNC_\K([^%]*)")