Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Databases and Redis

Building pgvector on Windows with nmake fails

ErrorPGROOT is not set

Short answer

pgvector on Windows is built from source with nmake in the x64 Native Tools Command Prompt, run as administrator. Three things break it: PGROOT is not set to your PostgreSQL folder, the Visual Studio C++ tools are missing, or the install step lacks admin rights to copy files into the PostgreSQL folder.

  • Applies to Windows 11, PostgreSQL 17, PostgreSQL 18, pgvector 0.8
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Open the 'x64 Native Tools Command Prompt for VS' (as administrator) and confirm nmake exists there and PGROOT points at a real folder.

    where nmake
    echo %PGROOT%
    dir "%PGROOT%\include\server\postgres.h"
  2. 2Match what you see, then jump to its fix

    1. 1PGROOT is not setPGROOT is not set, or points at the wrong folderFix
    2. 2nmake cannot be found in the prompt you are usingVisual Studio C++ support is not installed, or the wrong prompt is usedFix
    3. 3Access is denied (during nmake /F Makefile.win install)The install step cannot write into the PostgreSQL folderFix

What does the error look like?

  • PGROOT is not set
  • Access is denied
  • nmake: command not found in a normal cmd or PowerShell window

Cause 1 of 3

PGROOT is not set, or points at the wrong folder

1Check

pgvector's Windows makefile stops with this message when the variable is missing, and takes the bin, lib, share and include folders from it.

echo %PGROOT%
dir "%PGROOT%\bin\pg_config.exe"

2Fix

Set it to the PostgreSQL install folder for the same major version your server runs, in the same prompt window, then build again.

set "PGROOT=C:\Program Files\PostgreSQL\18"
cd %TEMP%
git clone --branch v0.8.7 https://github.com/pgvector/pgvector.git
cd pgvector
nmake /F Makefile.win

3Verify

nmake finishes without an error message.

nmake /F Makefile.win

Confirmed by raw.githubusercontent.com

Did this fix it?

Cause 2 of 3

Visual Studio C++ support is not installed, or the wrong prompt is used

1Check

The README asks for C++ support in Visual Studio and for the x64 Native Tools Command Prompt. A plain cmd or PowerShell window does not load the compiler paths.

where nmake

2Fix

Install C++ support through the Visual Studio Installer, then start the x64 Native Tools Command Prompt from the Start menu.

rem inside the x64 Native Tools Command Prompt
where nmake

3Verify

nmake prints a path.

where nmake

Confirmed by raw.githubusercontent.com

Did this fix it?

Cause 3 of 3

The install step cannot write into the PostgreSQL folder

1Check

The install target copies the DLL into PostgreSQL's lib folder and the control and SQL files into share\extension. Under Program Files that needs administrator rights.

dir "%PGROOT%\share\extension\vector*"

2Fix

Reopen the x64 Native Tools Command Prompt with Run as administrator and repeat the install step. Then enable the extension in the database.

nmake /F Makefile.win install
psql -U postgres -d mydb -c "CREATE EXTENSION vector;"

3Verify

The control file is present and the extension is listed.

dir "%PGROOT%\share\extension\vector.control"
psql -U postgres -d mydb -c "\dx vector"

Confirmed by raw.githubusercontent.com

Did this fix it?

How do I stop it coming back?

  • Pin the git tag in the clone command to a released version instead of building the main branch.
  • Rebuild pgvector after each PostgreSQL major version upgrade, with PGROOT pointing at the new folder.
  • Keep the build commands in a small script so every machine runs the same steps.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.