# PostgreSQL-8.3.5 init script fails with "postgres" not found

## mvmortier

[solved]

Hello, I just installed PostgreSQL-8.3.5 and ran emerge --config postgresql-server which worked fine without any errors.

When I try to start it now using

```
/etc/init.d/postgresql-8.3 start
```

I get this strange error:

```
* Starting PostgreSQL ...

The program "postgres" is needed by pg_ctl but was not found in the

same directory as "/usr/lib64/postgresql-8.3/bin/pg_ctl".

Check your installation.                                                                                                                          [ !! ]

 * The pid-file doesn't exist but pg_ctl reported a running server.

 * Please check whether there is another server running on the same port or read the log-file.  
```

If I look at the contents of the folder I get the following:

```
# ls /usr/lib64/postgresql-8.3/bin/

clusterdb  createlang  dropdb    dropuser  initdb    oid2name  pg_config       pg_ctl   pg_dumpall    pg_restore  postgres    psql       vacuumdb

createdb   createuser  droplang  ecpg      ipcclean  pgbench   pg_controldata  pg_dump  pg_resetxlog  pg_standby  postmaster  reindexdb  vacuumlo
```

So the program postgres is indeed there but it's being reported as missing. I already did

```
eselect postgresql set-all 8.3

eselect postgresql update
```

but that didn't help either. I still get this error.

Can anybody help me?

More general information: I run an amd64 system with some packages from ~amd64.

My emerge --info:

```
# emerge --info

Portage 2.1.6.2 (default/linux/amd64/2008.0/desktop, gcc-4.3.2, glibc-2.9_p20081201-r0, 2.6.27-gentoo-r7 x86_64)

=================================================================                                               

System uname: Linux-2.6.27-gentoo-r7-x86_64-AMD_Phenom-tm-_9950_Quad-Core_Processor-with-glibc2.2.5             

Timestamp of tree: Sun, 21 Dec 2008 12:45:01 +0000                                                              

app-shells/bash:     3.2_p33                                                                                    

dev-java/java-config: 1.3.7-r1, 2.1.6-r1                                                                        

dev-lang/python:     2.5.2-r7                                                                                   

dev-util/cmake:      2.6.2                                                                                      

sys-apps/baselayout: 1.12.11.1                                                                                  

sys-apps/sandbox:    1.2.18.1-r2                                                                                

sys-devel/autoconf:  2.13, 2.61-r2

sys-devel/automake:  1.5, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2, 1.10.1-r1

sys-devel/binutils:  2.18-r3

sys-devel/gcc-config: 1.4.0-r4

sys-devel/libtool:   1.5.26

virtual/os-headers:  2.6.23-r3

ACCEPT_KEYWORDS="amd64"

CBUILD="x86_64-pc-linux-gnu"

CFLAGS="-march=amdfam10 -O2 -finline-functions -pipe"

CHOST="x86_64-pc-linux-gnu"

CONFIG_PROTECT="/etc /usr/kde/3.5/env /usr/kde/3.5/share/config /usr/kde/3.5/shutdown /usr/kde/4.1/env /usr/kde/4.1/share/config /usr/kde/4.1/shutdown /usr/share/config /var/lib/hsqldb"

CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/eselect/postgresql /etc/fonts/fonts.conf /etc/gconf /etc/php/apache2-php5/ext-active/ /etc/php/cgi-php5/ext-active/ /etc/php/cli-php5/ext-active/ /etc/revdep-rebuild /etc/terminfo /etc/texmf/web2c /etc/udev/rules.d"

CXXFLAGS=""

DISTDIR="/usr/portage/distfiles"

FEATURES="distlocks fixpackages parallel-fetch protect-owned sandbox sfperms strict unmerge-orphans userfetch"

GENTOO_MIRRORS="http://de-mirror.org/distro/gentoo/ http://mirror.netcologne.de/gentoo/ "

LANG="de_DE.UTF-8"

LC_ALL="de_DE.UTF-8"

LDFLAGS="-Wl,-O1"

LINGUAS="de"

MAKEOPTS="-j5"

PKGDIR="/usr/portage/packages"

PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"

PORTAGE_TMPDIR="/var/tmp"

PORTDIR="/usr/portage"

SYNC="rsync://rsync.europe.gentoo.org/gentoo-portage"

USE="3dnow 7zip X a52 aac acl acpi alsa amd64 amr audiofile bash-completion berkdb branding bzip2 cairo cdda cddb cdio cdr cli cracklib crypt css cups curl dbus dhcp dri dts dvd dvdr dvdread eds emboss encode esd evo examples exif fam ffmpeg firefox flac fontconfig fortran gd gdbm gif glib gnutls gpm gstreamer gtk hal iconv id3tag ieee1394 imagemagick isdnlog java java6 jpeg jpeg2k kde kdeprefix lame lcms libnotify mad matroska midi mikmod mmx mmxext mp3 mp4 mpeg mudflap multilib musicbrainz ncurses network nls nptl nptlonly nsplugin ogg opengl openmp pcre pdf perl php png postgres ppds pppd python qt qt3 qt3support qt4 quicktime readline reflection samba schroedinger sdl session smp spell spl sqlite sse sse2 sse3 ssl ssse3 startup-notification svg sysfs taglib tcpd templates theora threads tiff truetype unicode usb vcd vorbis wavpack wmf x264 xml xorg xprint xulrunner xv xvid xvmc zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="alias asis auth_basic auth_digest autoindex cache cern_meta dir env expires ext_filter file_cache filter headers info log_config logio mime mime_magic negotiation rewrite setenvif speling status unique_id" APACHE2_MPMS="worker" ELIBC="glibc" INPUT_DEVICES="keyboard mouse evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="de" NETBEANS_MODULES="groovy gsf harness j2ee ide java nb websvccommon php visualweb webcommon xml" USERLAND="GNU" VIDEO_CARDS="radeon flgrx"

Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, FFLAGS, INSTALL_MASK, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, PORTDIR_OVERLAY
```

----------

## limn

Check the ownership and permissions of postgres, though that error looks spurious.

Is there another postmaster running?

Probably more useful would be to enable logging and try to start it again.

----------

## mvmortier

I solved the problem I just had to re-emerge it and then it worked.

----------

## n19i

I'm actually having this problem, not at starting it, but when running emerge --config.

As result, /var/lib/postgresql/8.3/data doesn't get populated.

Also, the init script fails with the same error as described by mvmortier.

I was upgrading to the new ebuilds using virtual/postgresql-base and etc. Then I ran into this problem and have been since trying all sorts of stuff to get postgresql to install again.

Downgrading to the old ebuilds didn't work.

I tried reset-all set-all using eselect postgresql, nothing.

I suspected some old files could be laying around, so I unmerged libpq postgresql postgresql-base postgresql-server, deleted users postgres and postmaster, then slocated and removed anything matching libpq postgresql postgres initdb psql that wasn't inside /usr/portage or /var/cache/edb/dep/usr/portage (I don't really know what's this folder for). Even init scripts and config files related to it. Removed /var/lib/postgresql folder. Everything.

Then I tried to emerge then and once again at emerge --config =dev-db/postgresql-server-8.3.5. Same error.

Also, I checked and rechecked the permissions at /usr/lib64/postgresql-8.3/bin ... they seem fine.

ps aux also says that there's no postmaster or anything running.

I also tried other versions of those virtual/postgresql-base virtual/postgresql-server ..

Note that its exactly the same error at the first post, except for pg_ctl:

```

* Checking system parameters...

* Checking whether your system supports at least 128 connections...

* Passed.

* Creating the data directory ...

* Initializing the database ...

The program "postgres" is needed by initdb but was not found in the

same directory as "/usr/lib64/postgresql-8.3/bin/initdb".

Check your installation.

```

Here's my emerge --info:

```

Portage 2.2_rc16 (default/linux/amd64/2008.0/desktop, gcc-4.1.2, glibc-2.9_p20081201-r0, 2.6.27-gentoo-r6 x86_64)

=================================================================

System uname: Linux-2.6.27-gentoo-r6-x86_64-AMD_Athlon-tm-_64_Processor_3700+-with-gentoo-2.0.0

Timestamp of tree: Fri, 30 Jan 2009 15:00:01 +0000

app-shells/bash:     3.2_p39

dev-java/java-config: 1.3.7-r1, 2.1.6-r1

dev-lang/python:     2.4.4-r14, 2.5.2-r7, 2.6.1

dev-util/cmake:      2.4.7-r1

sys-apps/baselayout: 2.0.0

sys-apps/openrc:     0.3.0-r1

sys-apps/sandbox:    1.2.18.1-r2

sys-devel/autoconf:  2.13, 2.63

sys-devel/automake:  1.4_p6, 1.5, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2, 1.10.2

sys-devel/binutils:  2.19

sys-devel/gcc-config: 1.4.0-r4

sys-devel/libtool:   1.5.26

virtual/os-headers:  2.6.27-r2

ACCEPT_KEYWORDS="amd64"

CBUILD="x86_64-pc-linux-gnu"

CFLAGS="-march=athlon64 -O2 -pipe -msse3"

CHOST="x86_64-pc-linux-gnu"

CONFIG_PROTECT="/etc"

CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/eselect/postgresql /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php5/ext-active/ /etc/php/cgi-php5/ext-active/ /etc/php/cli-php5/ext-active/ /etc/revdep-rebuild /etc/splash /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c /etc/udev/rules.d"

CXXFLAGS="-march=athlon64 -O2 -pipe -msse3"

DISTDIR="/usr/portage/distfiles/"

FEATURES="distlocks metadata-transfer parallel-fetch preserve-libs protect-owned sandbox sfperms strict unmerge-orphans userfetch"

GENTOO_MIRRORS="http://www.las.ic.unicamp.br/pub/gentoo/ "

LANG="de_DE.UTF-8"

LDFLAGS="-Wl,-O1"

LINGUAS="de fr pt_BR en br"

MAKEOPTS="-j2"

PKGDIR="/usr/portage/packages"

PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"

PORTAGE_TMPDIR="/var/tmp"

PORTDIR="/usr/portage"

PORTDIR_OVERLAY="/usr/portage/local/layman/haskell /usr/portage/local/layman/java-overlay /usr/portage/local/layman/libre_java_overlay /usr/portage/local/layman/nouveau-overlay /usr/portage/local/layman/ltsp /usr/portage/local/layman/java-experimental"

SYNC="rsync://rsync.gentoo.org/gentoo-portage"

USE="3dnow 3dnowext X a52 aac aalib accessibility acl alsa amd64 apache2 applet automount berkdb bittorrent bluetooth branding bzip2 cairo cdparanoia cdr cli cpudetection cpufreq cracklib crypt ctrlmenu cups curl cursors dbus divx dolphin dri dts dv dvb dvd dvdnav dvdr dvdread emboss encode equalizer evo exif fam ffmpeg flac foomaticdb fortran ftp gdbm gdm gif gimp glitz gmedia gnome gnome-keyring gphoto2 gpm gstreamer gtk hal icons iconv imlib ipod ipv6 isdnlog java java6 javascript jpeg jpeg2k kdeenablefinal kdehiddenvisibility kerberos lame ldap libnotify libwww logitech-mouse lyrics mad midi mikmod mmx mmxext mp3 mpeg msn mudflap multilib mysql nautilus ncurses networkmanager nls nptl nptlonly nsplugin nvidia nxclient ogg opengl openmp pam pcre pdf perl png postgres ppds pppd python qt3 qt3support qt4 quicktime readline realmedia reflection rss samba scanner session snmp spl sqlite3 sse sse2 ssl startup-notification svg swat sysfs syslog taglib tcpd tiff transparency truetype type1 unicode usb v4l v4l2 vcd vim-syntax vorbis wifi wiki winbind wmp x264 xcb xcomposite xml xorg xprint xulrunner xv xvid zlib" ALSA_CARDS="intel8x0" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" ELIBC="glibc" INPUT_DEVICES="keyboard mouse" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="de fr pt_BR en br" USERLAND="GNU" VIDEO_CARDS="nvidia nouveau"

Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, FFLAGS, INSTALL_MASK, LC_ALL, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS

```

----------

