1

I am installing some open source software by compiling its source code -- on Ubuntu 16.04 -- by following the instructions in its 'readme' file. At certain point (point 3b in the link) the guideline requires me to run a .csh file located in a certain directory in order to generate executables. When I execute the required csh script from the terminal in the required directory by typing ./compile_all.csh, or run csh to start an interactive shell, I am met with following line on terminal:

MANPATH: undefined variable. 

Can anyone guide me how can I fix this error?

The following is the result of the manpath command when executed from an Ubuntu terminal:

~$ manpath
/home/atrcheema/share/man:/usr/local/man:/usr/local/share/man:/usr/share/man

The ~./cshrc file contained just one line as seen by execution of following command:

:/home$ vim ~/.cshrc
setenv MANPATH ${MANPATH}:${HOME}/share/man

The first few lines of compile_all.csh are as follows:

#!/bin/csh

####### section added by York Prado 10/2009
if( ! (-e /usr/bin/f77 || -e /bin/f77 || -e /usr/local/bin/f77) ) then 
echo "f77 command is not found"
echo "Please make sure you have the fortran 77 compiler installed"
exit 1
endif 

# section below moved to compile_hspf_libs.csh
#cd hspf/lib3.2/src/util
#make clean 
#make 
#make install 
#cd ../ 
#cd wdm/
#make clean
#make 
#make install
#cd ../
#cd adwdm/
#make clean
##make
#make install
#echo "Compiled all the lib3.2 files needed to compile the CBWM"
#cd ../../../../ 

######### end York Prado section

cd lib/dsn/
f77 -c dsn_utils.f

cd ../util
rm ../util_lib.a
./compile
cd ../get
rm ../get_lib.a
./compile
cd ../tty/
gcc -c -o ../ttyux.o ttyux.c
derHugo
  • 3,376
  • 5
  • 34
  • 52

2 Answers2

2

The error message

MANPATH: undefined variable. 

is because Ubuntu doesn't set MANPATH by default (man has a built-in search path) and csh (unlike Bourne shells) doesn't treat unset variables as empty.

However it should not in itself prevent the shell OR any C-shell script from running.

Nevertheless, if you want to "fix" it, you will need to modify your ~/.cshrc file to check whether MANPATH is set or not and treat the two cases appropriately - something like

if ( ${?MANPATH} ) then 
  setenv MANPATH ${MANPATH}:${HOME}/share/man
else 
  setenv MANPATH ${HOME}/share/man
endif

DISCLAIMER I'm not fluent in csh syntax so YMMV.

derHugo
  • 3,376
  • 5
  • 34
  • 52
steeldriver
  • 142,475
1

Change ${MANPATH}:${HOME}/share/man to"`manpath`:$HOME/share/man".

Your ~/.cshrc file contains (and actually consists entirely of) a command whose intent is to augment the list of directories in which the man command will look for manual pages:

setenv MANPATH ${MANPATH}:${HOME}/share/man

However, that is not a generally correct way to achieve this, and it does not work for your situation, because the MANPATH environment variable does not exist. That's what produces your error message.1

The manpath command, which you found does work, automatically does the right thing. It checks if there is a MANPATH environment variable, and uses it if it exists (and is nonempty). But if there is no such environment variable (or it exists but is blank), manpath consults the configuration file /etc/manpath.config to determine what the default manpath should be, and uses that. When you set the MANPATH environment variable, the entries in that file are no longer automatically used, so you are responsible for ensuring that MANPATH contains them, except in the unusual case that you do not want them.2

Fortunately, this is easy to do, because you can just use command substitution to include the ouptut of the manpath command in the value assigned to the MANPATH variable. Replace the line ~/.cshrc currently contains with this:

setenv MANPATH "`manpath`:$HOME/share/man"

Backticks (` `) perform command substitution in csh and tcsh. In Bourne-style shells like bash, there is also a $( ) syntax for command substitution, which is generally preferable to backticks, but that does not apply to C shells. You can't use the $( ) syntax with csh/tcsh; they don't support it.


1 However, as steeldriver says, you can probably proceed without fixing this problem. Most scripts don't use the man command, though some may. Even if your script installs software that includes manual pages, it will likely not consult the current manpath to figure out where to put them. Of course, if its documentation says it does, then that supersedes this guess. I do suggest you fix this problem, but you can likely proceed without doing so.

2 The man command uses the same procedure to decide where to look for manual pages, possibly by calling manpath. See manpath(5) (man 5 manpath), which says, "If the environment variable $MANPATH is already set, the information contained within /etc/manpath.config will not override it." I have confirmed, by testing, that this is the case. For example, running env MANPATH=. man tcsh from your home directory will say No manual entry for tcsh.

Eliah Kagan
  • 119,640