You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by "Lane Schwartz (JIRA)" <ji...@apache.org> on 2012/07/13 21:19:34 UTC

[jira] [Commented] (HADOOP-6101) CDPATH environment variable causes bin scripts to fail.

    [ https://issues.apache.org/jira/browse/HADOOP-6101?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13413973#comment-13413973 ] 

Lane Schwartz commented on HADOOP-6101:
---------------------------------------

This problem occurs when CDPATH is set and includes "." (the present working directory). It is unsafe to assume that cd will not print to standard output.

The bash documentation states:

{quote}
If a non-empty directory name from CDPATH is used, or if ‘-’ is the first argument, and the directory change is successful, the absolute pathname of the new working directory is written to the standard output. 
{quote}

Steps to recreate:

1. export CDPATH=.
2. Run any hadoop script that contains the offending bin=`cd "$bin"; pwd` line

In this case, because CDPATH includes "." and the current value of $bin is "." an invocation of "cd" will cause the current absolute path to be printed to standard output. I have verified this problem occurs under these circumstances using bash 4.1.2(1) on Scientific Linux 6.2.

As stated above, the safest fix is to find all instances of the following:

{code}
bin=`cd "$bin"; pwd`
{code}

and replace the above with the following:

{code}
bin=`cd "$bin" &> /dev/null; pwd`
{code}

                
> CDPATH environment variable causes bin scripts to fail.
> -------------------------------------------------------
>
>                 Key: HADOOP-6101
>                 URL: https://issues.apache.org/jira/browse/HADOOP-6101
>             Project: Hadoop Common
>          Issue Type: Bug
>          Components: scripts
>    Affects Versions: 0.19.1
>            Reporter: Phil Hagelberg
>            Priority: Minor
>
> Most of the scripts in bin/* assume that cd produces no output. But when using bash (and some other shells) cd will output the destination directory if the CDPATH environment variable is set. CDPATH is very useful, and it's unfortunate to have to unset it to use Hadoop.
> The offending line (in start-all.sh, though most of the scripts exhibit the problem) is:
>   bin=`cd "$bin"; pwd`
> Adding this to the top of each affected script will fix the problem:
>   unset CDPATH

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira