Thread: New User: PostgreSQL Setup - "The Program 'postgress' is needed by initdb but was not found in the same directory..."

Hello,

I'm new to PostgreSQL, but am trying to set up a server on my machine.  The PostgreSQL server is to run inside of a LXC
container- I'm not sure if this is contributing to my problem or not, but it's worth mentioning.  The main OS (host) of
mymachine is  Ubuntu 11.10 (mostly, some packages are updated to newer versions), and my guest OS (inside the
container)is Debian.  I compiled PostgreSQL from source, and installed it inside the container.  However, I did have to
usethe "without zlib" and "without readline" options to compile.  This is strange, as both libraries are installed
(confirmedvia aptitude).   

I'm following the instructions that come with the source, and am stuck on this line:

/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data

When I run it, I get the following:

sh: cannot create /dev/null: Permission denied
fgets failure: Success
The program "postgres" is needed by initdb but was not found in the
same directory as "/usr/local/pgsql/bin/initdb".
Check your installation.

initdb and postgres both reside in /usr/local/pgsql/bin, which I've also added to my PATH.  Any help would be
appreciated. I was hoping PostgreSQL would be reasonably straightforward to install.  So far I've tried the Ubuntu
tutorials,as well as one or two others online.  Now I'm installing from source and using a mailing list....so much for
simplicity.  

I realize using LXC containers may add a layer of complexity, but what is it that I'm missing here?

On Dec 15, 2011, at 10:12 PM, Patrick Kevin McCaffrey wrote:

> Hello,
>
> I'm new to PostgreSQL, but am trying to set up a server on my machine.  The PostgreSQL server is to run inside of a
LXCcontainer - I'm not sure if this is contributing to my problem or not, but it's worth mentioning.  The main OS
(host)of my machine is  Ubuntu 11.10 (mostly, some packages are updated to newer versions), and my guest OS (inside the
container)is Debian.  I compiled PostgreSQL from source, and installed it inside the container.  However, I did have to
usethe "without zlib" and "without readline" options to compile.  This is strange, as both libraries are installed
(confirmedvia aptitude).   

The development packages for them may not be installed - zlib1g-dev and libreadline-dev - without those, you can't
buildapplications against those libraries. 

> I'm following the instructions that come with the source, and am stuck on this line:
>
> /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
>
> When I run it, I get the following:
>
> sh: cannot create /dev/null: Permission denied

This line suggests that your environment is broken - the chroot container hasn't been set up fully.

> fgets failure: Success

This isn't good, either. I'm suspicious of your lxc chroot.

> The program "postgres" is needed by initdb but was not found in the
> same directory as "/usr/local/pgsql/bin/initdb".

This suggests that your build broke. Is there a /usr/local/pgsql/bin/postgres binary?

> Check your installation.
>
> initdb and postgres both reside in /usr/local/pgsql/bin, which I've also added to my PATH.  Any help would be
appreciated. I was hoping PostgreSQL would be reasonably straightforward to install.  So far I've tried the Ubuntu
tutorials,as well as one or two others online.  Now I'm installing from source and using a mailing list....so much for
simplicity.  
>
> I realize using LXC containers may add a layer of complexity, but what is it that I'm missing here?


LXC is definitely part of your problem - it sounds like your chroot isn't being set up correctly.

Once that's fixed, you'd still be better installing postgresql from apt. If, for some reason, you need to build it from
sourceI'd suggest building it on your host (Ubuntu) first, so you can see what a build looks like on a working platform
beforetrying to build it in the lxc chroot. 

Cheers,
  Steve


> Hello,
>
> I'm new to PostgreSQL, but am trying to set up a server on my machine.  The PostgreSQL server is to run inside of a
LXCcontainer - I'm not sure if this is contributing to my problem or not, but it's worth mentioning.  The main OS
(host)of my machine is  Ubuntu 11.10 (mostly, some packages are updated to newer versions), and my guest OS (inside the
container)is Debian.  I compiled PostgreSQL from source, and installed it inside the container.  However, I did have to
usethe "without zlib" and "without readline" options to compile.  This is strange, as both libraries are installed
(confirmedvia aptitude).   

The development packages for them may not be installed - zlib1g-dev and libreadline-dev - without those, you can't
buildapplications against those libraries. 

> I'm following the instructions that come with the source, and am stuck on this line:
>
> /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
>
> When I run it, I get the following:
>
> sh: cannot create /dev/null: Permission denied

This line suggests that your environment is broken - the chroot container hasn't been set up fully.

> fgets failure: Success

This isn't good, either. I'm suspicious of your lxc chroot.

> The program "postgres" is needed by initdb but was not found in the
> same directory as "/usr/local/pgsql/bin/initdb".

This suggests that your build broke. Is there a /usr/local/pgsql/bin/postgres binary?

> Check your installation.
>
> initdb and postgres both reside in /usr/local/pgsql/bin, which I've also added to my PATH.  Any help would be
appreciated. I was hoping PostgreSQL would be reasonably straightforward to install.  So far I've tried the Ubuntu
tutorials,as well as one or two others online.  Now I'm installing from source and using a mailing list....so much for
simplicity.  
>
> I realize using LXC containers may add a layer of complexity, but what is it that I'm missing here?


LXC is definitely part of your problem - it sounds like your chroot isn't being set up correctly.

Once that's fixed, you'd still be better installing postgresql from apt. If, for some reason, you need to build it from
sourceI'd suggest building it on your host (Ubuntu) first, so you can see what a build looks like on a working platform
beforetrying to build it in the lxc chroot. 


>>>Thanks for the reply.  I actually tried installing via apt before building from source, and I got the same results
thatI have now.  I'm a bit confused, as the container appears to work correctly.  I set it up a template using
debootstrap,and have been copying that template container (and editing the necessary files, like
/etc/network/interfacesand such).  On of my containers runs an email server (Dovecot and Postfix), and everything
appearsto work fine there. 

I'll try installing PG on the host side (Ubuntu) and see what I get.  Also, I'll probably send out an email to the LXC
mailinglist and see what they think. 

Pat


--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Patrick Kevin McCaffrey <pkm@uwm.edu> writes:
>> I'm following the instructions that come with the source, and am stuck on this line:
>> /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
>> When I run it, I get the following:
>> sh: cannot create /dev/null: Permission denied

> This line suggests that your environment is broken - the chroot container hasn't been set up fully.

>> fgets failure: Success

> This isn't good, either. I'm suspicious of your lxc chroot.

>> The program "postgres" is needed by initdb but was not found in the
>> same directory as "/usr/local/pgsql/bin/initdb".

> This suggests that your build broke. Is there a /usr/local/pgsql/bin/postgres binary?

I think nobody pointed out yet that those last two messages are almost
certainly direct results of the first one.  initdb tries to verify that
the postgres binary is of a matching version by doing (more or less,
this isn't cut-and-pasted from the sources)

    system("postgres -V 2>/dev/null")

and seeing what version string it gets back.  If /dev/null isn't
writable inside your LXC chroot, then the shell will fail to execute
that command (producing the first error message), and what initdb will
get back is only an empty string, which I think explains the "fgets"
whinge and definitely explains the wrong-version complaint.

            regards, tom lane