Re: BUG #5267: initdb fails on AIX: could not identify current directory

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Michael Felt <mamfelt(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5267: initdb fails on AIX: could not identify current directory
Date: 2010-01-07 15:25:38
Message-ID: 603c8f071001070725u67446582vb2745793be30fbc1@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Thu, Jan 7, 2010 at 10:00 AM, Michael Felt <mamfelt(at)gmail(dot)com> wrote:
> michael(at)x054:[/data/prj/postgresql-8.4.2/src]grep cwd */*.c
> Well, unless you redefine it...
> port/exec.c:#define getcwd(cwd,len) GetCurrentDirectory(len, cwd)

If you look at the context of this #define you'll see that it only
applies to Windows.

> port/exec.c:    char            cwd[MAXPGPATH],
> port/exec.c:    if (!getcwd(cwd, MAXPGPATH))
> port/exec.c:                    join_path_components(retpath, cwd, argv0);
> port/exec.c:    join_path_components(retpath, cwd, argv0);
> port/exec.c:                            join_path_components(retpath, cwd,
> test_path);
> port/exec.c:     * getcwd() to figure out where the heck we're at.
> port/exec.c:     * getcwd() to give us an accurate, symlink-free path.
> port/exec.c:    if (!getcwd(orig_wd, MAXPGPATH))
> port/exec.c:    if (!getcwd(path, MAXPGPATH))
>
>
> Now I have no idea what is being called. I hope you do.

It looks to me like bin/initdb/initdb.c:main() is calling
port/exec.c:find_other_exec() which is calling
port/exec.c:find_my_exec() which is calling getcwd(). So it's
probably the directory you were in when you ran initdb that is the
problem. For example:

cd $HOME
mkdir delete-me
cd delete-me
rmdir $HOME/delete-me
initdb

Produces:

could not identify current directory: No such file or directory
could not identify current directory: No such file or directory
could not identify current directory: No such file or directory
The program "postgres" is needed by initdb but was not found in the
same directory as "initdb".
Check your installation.

This is very similar to what you got except that for you it's
complaining about permissions rather than existence. I would try
running initdb from someplace like / or /tmp and see if that works.

I have to say that the error message that is produced by the above
test case could easily send one looking in the wrong direction, and
could perhaps stand to be improved. Could we just do getcwd() once,
bail out if it fails, and then stash the results, rather than
continuing on and eventually producing a misleading error message?

...Robert

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Michael Felt 2010-01-07 15:47:04 Re: BUG #5267: initdb fails on AIX: could not identify current directory
Previous Message Robert Haas 2010-01-07 15:08:14 Re: email addresses