Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wuAf2-000ViR-1K for pgsql-bugs@arkaria.postgresql.org; Wed, 12 Aug 2026 15:14:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wuAey-008YQ6-1q for pgsql-bugs@arkaria.postgresql.org; Wed, 12 Aug 2026 15:14:29 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wuAey-008YPv-11 for pgsql-bugs@lists.postgresql.org; Wed, 12 Aug 2026 15:14:29 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wuAet-00000000NRS-1GX8 for pgsql-bugs@lists.postgresql.org; Wed, 12 Aug 2026 15:14:29 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.18.1/8.18.1) with ESMTP id 67CFEGTg2642396; Wed, 12 Aug 2026 11:14:16 -0400 From: Tom Lane To: Holger Jakobs cc: pgsql-bugs@lists.postgresql.org Subject: Re: pg_upgrade from 17.10 to 18.4 on Ubuntu fails: Finding the real data directory for the target cluster sh: 1: (null)/postgres: not found In-reply-to: References: Comments: In-reply-to Holger Jakobs message dated "Wed, 12 Aug 2026 12:50:57 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <2642394.1786547656.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Wed, 12 Aug 2026 11:14:16 -0400 Message-ID: <2642395.1786547656@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk [ redirecting to pgsql-bugs ] Holger Jakobs writes: > Dear Friends, > Today a pg_upgrade failed with this awkward message: > Finding the real data directory for the source cluster        ok > Finding the real data directory for the target cluster        sh: 1: > (null)/postgres: not found I can reproduce this if (1) I omit -B (and don't give PGBINNEW either), and (2) the target -D directory is a config-only directory, that is it contains postgresql.conf but not PG_VERSION. Given (1), pg_upgrade is supposed to assume that -B should be the directory that it itself was executed from. However, that is filled in by setup(), which does not run till after adjust_data_dir(), which is reaching the "Finding the real data directory" bit because of (2). So we arrive there with cluster->bindir still NULL, and kaboom. So the temporary workaround for Holger is to specify -B explicitly, but somebody needs to rethink the order of initialization steps here. Maybe just move that bit of setup() into parseCommandLine()? It looks like this is an error of pretty long standing... regards, tom lane