SUMMARY: Problem with make

From: Mark S. Anderson (anderson@neon.mitre.org)
Date: Tue Aug 02 1994 - 01:22:24 CDT


Thanks to both of you who responded. ;-)

I have some additional information about the problem and a solution.
The problem was with /bin/sh rather than make.

Original Question:
>
> I am running the c shell, and I just finished building gcc-2.6.0 as
> user anderson (all files owned by anderson). Then I become superuser.
> When I try to:
>
> `make install CC="stage2/xgcc -Bstage2/" CFLAGS="-g -O" LANGUAGES=c'
>
> I get this error:
>
> (cd include; \
> tar -cf - .; exit 0) | (cd >/usr/local/lib/gcc-lib/sparc-sun-sunos4.1.1/2.6.0/include; tar xpBf - )
> sh: include: bad directory
> tar: read error: unexpected EOF
> *** Error code 3
> make: Fatal error: Command failed for target `install-headers-tar'
>
> If I give the same command from the shell prompt, it works fine:
>
> ROOT neon:/data1/gcc-2.6.0 # (cd include; \
> tar -cf - .; exit 0) | (cd >/usr/local/lib/gcc-lib/sparc-sun-sunos4.1.1/2.6.0/include; tar xpBf - )
>
> I also had this problem doing a `make distclean'. I even tried changing
> all file ownerships to root, but that was no help.
>
> Does anyone have ANY idea what is going on?

Solution:
---------
Either remove CDPATH from the environment, or be sure that it includes
the current directory.

What Was Happening:
-------------------
CDPATH was being set in root's .cshrc which was read when su was
executed. CDPATH did not include `.'. Root was able to change
directories normally, because he was using the csh. Apparently, csh
looks at CDPATH only after looking in the current directory. But when
root executed sh, either on the command line, or through make, the
environment containing CDPATH is retained. If CDPATH is defined, it
appears that sh looks at it exclusively when a relative path name is
given as an argument to the cd command.

Summary of experimental results:
--------------------------------
When /bin/csh is root's login shell, and /bin/sh is executed, the shell
fails to recognize relative paths. This does not happen if ANY of
the following are true:

  - root's login shell is /bin/sh (since .profile is not read by su)
  - the current directory (`.') is added to CDPATH
  - CDPATH is undefined

Here follows a description of the very odd behavior:

----------
The 1st scenario:
 
The setup:
 - I am an ordinary user, running csh.
 - My PATH includes `.' near the end of the path, set in .login
 - The login shell for root is /bin/csh.
 - Root has no aliases for 'cd'.
 - /data1 is nfs mounted with root permission for my host.
 - My host is an NIS master.
 - Running 4.1.1 on 4/370

The attempt:
 - I su to root (not 'su -') and give the password.
 - I cd to /data1/gcc-2.6.0
 - When I try to 'make clean' it fails on this rule:

   if [ -d objc ]; then \
     srcdir1=`cd .; pwd`; \
     cd objc; make -f $srcdir1/objc/Makefile mostlyclean; \
   else true; fi
   sh: objc: bad directory
   *** Error code 1
   make: Fatal error: Command failed for target `mostlyclean'

 - I can list objc and I can 'cd' to it. (Remember, I'm root
   running csh.)

-----------
The 2nd scenario:

The setup
 - Same as 1st setup, except that the login shell for root is
   /bin/sh. NIS maps were rebuilt.

The attempt:
 - I `su' to root
 - there are NO problems running make or changing directories.

-----------
The 3rd scenario:

The setup:
 - Same as 1st setup (root login shell is csh)

The Attempt:
 - I su to root (not 'su -') and give the password.
 - I exececute sh: # sh or # exec sh
 - I cd to /data1/gcc-2.6.0
 - Make fails as in attempt #1
 - I can list the subdirectory, but I cannot cd to it:
     # cd objc
     objc: bad directory

 - In fact, I cannot `cd' to ANY directory using relative paths:
     # cd /
     # pwd
     /
     # cd data1
     data1: bad directory
     # cd /data1
     # pwd
     /data1
     # cd gcc-2.6.0
     gcc-2.6.0: bad directory
     # cd ./gcc-2.6.0
     # pwd
     /data1/gcc-2.6.0

 - There is no improvement if is use `su -' to become root.

----------
The 4th scenario:

 - I added . to the CDPATH variable (and exported it)
 - Problem solved! I can cd using relative paths, and the make
   works properly.
 - Deleting CDPATH also solves the problem: # unset CDPATH

Mark Anderson
----------------------------------------------------------
The MITRE Corporation manderso@mitre.org
7525 Colshire Drive, MS W747 voice: (703) 883-6439
McLean, VA 22102 FAX: (703) 883-1905

----- End Included Message -----

Mark Anderson
----------------------------------------------------------
The MITRE Corporation manderso@mitre.org
7525 Colshire Drive, MS W747 voice: (703) 883-6439
McLean, VA 22102 FAX: (703) 883-1905



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:09:06 CDT