Need help with postgresql build on windows

Started by Prafulla Ranadive7 days ago5 messages
#1Prafulla Ranadive
pprandive.pgsql@gmail.com

Hello,

I have started exploring Postgresql recently.
I am trying to build Postgresql from source on a windows machine. I am
referring to the page
https://www.postgresql.org/docs/current/install-meson.html#INSTALL-SHORT-MESON

The ninja command is failing with the error message:

PS C:\PostgreSQLworkspace\postgres\build> ninja
[142/2102] Generating src/fe_utils/psqlscan with a custom command

FAILED: src/fe_utils/psqlscan.c
"C:\MyPrograms\Meson\meson.exe" "runpython" "../src/tools/pgflex"
"--builddir" "." "--srcdir" ".." "--privatedir" "src/fe_utils/psqlscan.c.p"
"--flex" "C:\MyPrograms\GnuWin32\bin\flex.EXE" "--perl"
"C:\Strawberry\perl\bin\perl.EXE" "-i" "../src/fe_utils/psqlscan.l" "-o"
"src/fe_utils/psqlscan.c" "--no-backup" "--" "-Cfe" "-p" "-p"
C:\MyPrograms\GnuWin32\bin\flex.EXE: can't open
C:\PostgreSQLworkspace\postgres\build\src\fe_utils\psqlscan.c
[146/2102] Generating src/backend/bootstrap/bootscanner with a custom
command
FAILED: src/backend/bootstrap/bootscanner.c
"C:\MyPrograms\Meson\meson.exe" "runpython" "../src/tools/pgflex"
"--builddir" "." "--srcdir" ".." "--privatedir"
"src/backend/bootstrap/bootscanner.c.p" "--flex"
"C:\MyPrograms\GnuWin32\bin\flex.EXE" "--perl"
"C:\Strawberry\perl\bin\perl.EXE" "-i"
"../src/backend/bootstrap/bootscanner.l" "-o"
"src/backend/bootstrap/bootscanner.c"
C:\MyPrograms\GnuWin32\bin\flex.EXE: can't open
C:\PostgreSQLworkspace\postgres\build\src\backend\bootstrap\bootscanner.c
[147/2102] Generating src/backend/parser/scan with a custom command
FAILED: src/backend/parser/scan.c
"C:\MyPrograms\Meson\meson.exe" "runpython" "../src/tools/pgflex"
"--builddir" "." "--srcdir" ".." "--privatedir"
"src/backend/parser/scan.c.p" "--flex"
"C:\MyPrograms\GnuWin32\bin\flex.EXE" "--perl"
"C:\Strawberry\perl\bin\perl.EXE" "-i" "../src/backend/parser/scan.l" "-o"
"src/backend/parser/scan.c" "--no-backup" "--" "-CF" "-p" "-p"
C:\MyPrograms\GnuWin32\bin\flex.EXE: can't open
C:\PostgreSQLworkspace\postgres\build\src\backend\parser\scan.c
ninja: build stopped: subcommand failed.
PS C:\PostgreSQLworkspace\postgres\build>

I have enabled full permission on the folder but still no luck.

Can someone please help me with this? Any troubleshooting pointers would be
a great help!

Thanks in advance!

Thanks and Regards,
Prafulla

#2Nazir Bilal Yavuz
byavuz81@gmail.com
In reply to: Prafulla Ranadive (#1)
Re: Need help with postgresql build on windows

Hi,

On Mon, 5 Jan 2026 at 08:28, Prafulla Ranadive
<pprandive.pgsql@gmail.com> wrote:

Hello,

I have started exploring Postgresql recently.
I am trying to build Postgresql from source on a windows machine. I am referring to the page https://www.postgresql.org/docs/current/install-meson.html#INSTALL-SHORT-MESON

The ninja command is failing with the error message:

PS C:\PostgreSQLworkspace\postgres\build> ninja
[142/2102] Generating src/fe_utils/psqlscan with a custom command
FAILED: src/fe_utils/psqlscan.c
"C:\MyPrograms\Meson\meson.exe" "runpython" "../src/tools/pgflex" "--builddir" "." "--srcdir" ".." "--privatedir" "src/fe_utils/psqlscan.c.p" "--flex" "C:\MyPrograms\GnuWin32\bin\flex.EXE" "--perl" "C:\Strawberry\perl\bin\perl.EXE" "-i" "../src/fe_utils/psqlscan.l" "-o" "src/fe_utils/psqlscan.c" "--no-backup" "--" "-Cfe" "-p" "-p"
C:\MyPrograms\GnuWin32\bin\flex.EXE: can't open C:\PostgreSQLworkspace\postgres\build\src\fe_utils\psqlscan.c
[146/2102] Generating src/backend/bootstrap/bootscanner with a custom command
FAILED: src/backend/bootstrap/bootscanner.c
"C:\MyPrograms\Meson\meson.exe" "runpython" "../src/tools/pgflex" "--builddir" "." "--srcdir" ".." "--privatedir" "src/backend/bootstrap/bootscanner.c.p" "--flex" "C:\MyPrograms\GnuWin32\bin\flex.EXE" "--perl" "C:\Strawberry\perl\bin\perl.EXE" "-i" "../src/backend/bootstrap/bootscanner.l" "-o" "src/backend/bootstrap/bootscanner.c"
C:\MyPrograms\GnuWin32\bin\flex.EXE: can't open C:\PostgreSQLworkspace\postgres\build\src\backend\bootstrap\bootscanner.c
[147/2102] Generating src/backend/parser/scan with a custom command
FAILED: src/backend/parser/scan.c
"C:\MyPrograms\Meson\meson.exe" "runpython" "../src/tools/pgflex" "--builddir" "." "--srcdir" ".." "--privatedir" "src/backend/parser/scan.c.p" "--flex" "C:\MyPrograms\GnuWin32\bin\flex.EXE" "--perl" "C:\Strawberry\perl\bin\perl.EXE" "-i" "../src/backend/parser/scan.l" "-o" "src/backend/parser/scan.c" "--no-backup" "--" "-CF" "-p" "-p"
C:\MyPrograms\GnuWin32\bin\flex.EXE: can't open C:\PostgreSQLworkspace\postgres\build\src\backend\parser\scan.c
ninja: build stopped: subcommand failed.
PS C:\PostgreSQLworkspace\postgres\build>

I have enabled full permission on the folder but still no luck.

Can someone please help me with this? Any troubleshooting pointers would be a great help!

Could you let me know where you downloaded flex from? I am wondering
whether it might be this:
https://gnuwin32.sourceforge.net/packages/flex.htm.

For our Windows CI, we use flex and bison from this release instead:
https://github.com/lexxmark/winflexbison/releases/tag/v2.5.24.

If you have a chance, would you mind trying flex and bison from that
source to see if it helps?

--
Regards,
Nazir Bilal Yavuz
Microsoft

#3Prafulla Ranadive
pprandive.pgsql@gmail.com
In reply to: Nazir Bilal Yavuz (#2)
Re: Need help with postgresql build on windows

Hi Nazir,

Thank you for your email. Sure, I will try using flex bison from link
shared by you.
I have stepped out for some personal work so I will be able to try out only
after 4 hours from now.
I will let you know as soon as I try that out. Once again thank you so much.

Regards,
Prafulla

On Mon, 5 Jan, 2026, 12:09 pm Nazir Bilal Yavuz, <byavuz81@gmail.com> wrote:

Show quoted text

Hi,

On Mon, 5 Jan 2026 at 08:28, Prafulla Ranadive
<pprandive.pgsql@gmail.com> wrote:

Hello,

I have started exploring Postgresql recently.
I am trying to build Postgresql from source on a windows machine. I am

referring to the page
https://www.postgresql.org/docs/current/install-meson.html#INSTALL-SHORT-MESON

The ninja command is failing with the error message:

PS C:\PostgreSQLworkspace\postgres\build> ninja
[142/2102] Generating src/fe_utils/psqlscan with a custom command
FAILED: src/fe_utils/psqlscan.c
"C:\MyPrograms\Meson\meson.exe" "runpython" "../src/tools/pgflex"

"--builddir" "." "--srcdir" ".." "--privatedir" "src/fe_utils/psqlscan.c.p"
"--flex" "C:\MyPrograms\GnuWin32\bin\flex.EXE" "--perl"
"C:\Strawberry\perl\bin\perl.EXE" "-i" "../src/fe_utils/psqlscan.l" "-o"
"src/fe_utils/psqlscan.c" "--no-backup" "--" "-Cfe" "-p" "-p"

C:\MyPrograms\GnuWin32\bin\flex.EXE: can't open

C:\PostgreSQLworkspace\postgres\build\src\fe_utils\psqlscan.c

[146/2102] Generating src/backend/bootstrap/bootscanner with a custom

command

FAILED: src/backend/bootstrap/bootscanner.c
"C:\MyPrograms\Meson\meson.exe" "runpython" "../src/tools/pgflex"

"--builddir" "." "--srcdir" ".." "--privatedir"
"src/backend/bootstrap/bootscanner.c.p" "--flex"
"C:\MyPrograms\GnuWin32\bin\flex.EXE" "--perl"
"C:\Strawberry\perl\bin\perl.EXE" "-i"
"../src/backend/bootstrap/bootscanner.l" "-o"
"src/backend/bootstrap/bootscanner.c"

C:\MyPrograms\GnuWin32\bin\flex.EXE: can't open

C:\PostgreSQLworkspace\postgres\build\src\backend\bootstrap\bootscanner.c

[147/2102] Generating src/backend/parser/scan with a custom command
FAILED: src/backend/parser/scan.c
"C:\MyPrograms\Meson\meson.exe" "runpython" "../src/tools/pgflex"

"--builddir" "." "--srcdir" ".." "--privatedir"
"src/backend/parser/scan.c.p" "--flex"
"C:\MyPrograms\GnuWin32\bin\flex.EXE" "--perl"
"C:\Strawberry\perl\bin\perl.EXE" "-i" "../src/backend/parser/scan.l" "-o"
"src/backend/parser/scan.c" "--no-backup" "--" "-CF" "-p" "-p"

C:\MyPrograms\GnuWin32\bin\flex.EXE: can't open

C:\PostgreSQLworkspace\postgres\build\src\backend\parser\scan.c

ninja: build stopped: subcommand failed.
PS C:\PostgreSQLworkspace\postgres\build>

I have enabled full permission on the folder but still no luck.

Can someone please help me with this? Any troubleshooting pointers would

be a great help!

Could you let me know where you downloaded flex from? I am wondering
whether it might be this:
https://gnuwin32.sourceforge.net/packages/flex.htm.

For our Windows CI, we use flex and bison from this release instead:
https://github.com/lexxmark/winflexbison/releases/tag/v2.5.24.

If you have a chance, would you mind trying flex and bison from that
source to see if it helps?

--
Regards,
Nazir Bilal Yavuz
Microsoft

#4Prafulla Ranadive
pprandive.pgsql@gmail.com
In reply to: Prafulla Ranadive (#3)
Re: Need help with postgresql build on windows

Hi Nazir,

My problem got resolved after using the flex bison from the link you
provided. Thank you so much!

Thanks and Regards,
Prafulla

On Mon, Jan 5, 2026 at 12:54 PM Prafulla Ranadive <pprandive.pgsql@gmail.com>
wrote:

Show quoted text

Hi Nazir,

Thank you for your email. Sure, I will try using flex bison from link
shared by you.
I have stepped out for some personal work so I will be able to try out
only after 4 hours from now.
I will let you know as soon as I try that out. Once again thank you so
much.

Regards,
Prafulla

On Mon, 5 Jan, 2026, 12:09 pm Nazir Bilal Yavuz, <byavuz81@gmail.com>
wrote:

Hi,

On Mon, 5 Jan 2026 at 08:28, Prafulla Ranadive
<pprandive.pgsql@gmail.com> wrote:

Hello,

I have started exploring Postgresql recently.
I am trying to build Postgresql from source on a windows machine. I am

referring to the page
https://www.postgresql.org/docs/current/install-meson.html#INSTALL-SHORT-MESON

The ninja command is failing with the error message:

PS C:\PostgreSQLworkspace\postgres\build> ninja
[142/2102] Generating src/fe_utils/psqlscan with a custom command
FAILED: src/fe_utils/psqlscan.c
"C:\MyPrograms\Meson\meson.exe" "runpython" "../src/tools/pgflex"

"--builddir" "." "--srcdir" ".." "--privatedir" "src/fe_utils/psqlscan.c.p"
"--flex" "C:\MyPrograms\GnuWin32\bin\flex.EXE" "--perl"
"C:\Strawberry\perl\bin\perl.EXE" "-i" "../src/fe_utils/psqlscan.l" "-o"
"src/fe_utils/psqlscan.c" "--no-backup" "--" "-Cfe" "-p" "-p"

C:\MyPrograms\GnuWin32\bin\flex.EXE: can't open

C:\PostgreSQLworkspace\postgres\build\src\fe_utils\psqlscan.c

[146/2102] Generating src/backend/bootstrap/bootscanner with a custom

command

FAILED: src/backend/bootstrap/bootscanner.c
"C:\MyPrograms\Meson\meson.exe" "runpython" "../src/tools/pgflex"

"--builddir" "." "--srcdir" ".." "--privatedir"
"src/backend/bootstrap/bootscanner.c.p" "--flex"
"C:\MyPrograms\GnuWin32\bin\flex.EXE" "--perl"
"C:\Strawberry\perl\bin\perl.EXE" "-i"
"../src/backend/bootstrap/bootscanner.l" "-o"
"src/backend/bootstrap/bootscanner.c"

C:\MyPrograms\GnuWin32\bin\flex.EXE: can't open

C:\PostgreSQLworkspace\postgres\build\src\backend\bootstrap\bootscanner.c

[147/2102] Generating src/backend/parser/scan with a custom command
FAILED: src/backend/parser/scan.c
"C:\MyPrograms\Meson\meson.exe" "runpython" "../src/tools/pgflex"

"--builddir" "." "--srcdir" ".." "--privatedir"
"src/backend/parser/scan.c.p" "--flex"
"C:\MyPrograms\GnuWin32\bin\flex.EXE" "--perl"
"C:\Strawberry\perl\bin\perl.EXE" "-i" "../src/backend/parser/scan.l" "-o"
"src/backend/parser/scan.c" "--no-backup" "--" "-CF" "-p" "-p"

C:\MyPrograms\GnuWin32\bin\flex.EXE: can't open

C:\PostgreSQLworkspace\postgres\build\src\backend\parser\scan.c

ninja: build stopped: subcommand failed.
PS C:\PostgreSQLworkspace\postgres\build>

I have enabled full permission on the folder but still no luck.

Can someone please help me with this? Any troubleshooting pointers

would be a great help!

Could you let me know where you downloaded flex from? I am wondering
whether it might be this:
https://gnuwin32.sourceforge.net/packages/flex.htm.

For our Windows CI, we use flex and bison from this release instead:
https://github.com/lexxmark/winflexbison/releases/tag/v2.5.24.

If you have a chance, would you mind trying flex and bison from that
source to see if it helps?

--
Regards,
Nazir Bilal Yavuz
Microsoft

#5Nazir Bilal Yavuz
byavuz81@gmail.com
In reply to: Prafulla Ranadive (#4)
Re: Need help with postgresql build on windows

Hi Prafulla,

On Mon, 5 Jan 2026 at 13:04, Prafulla Ranadive
<pprandive.pgsql@gmail.com> wrote:

Hi Nazir,

My problem got resolved after using the flex bison from the link you provided. Thank you so much!

I am glad it worked!

--
Regards,
Nazir Bilal Yavuz
Microsoft