Building pgvector on Windows with nmake fails
PGROOT is not setShort 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.
Fix it fast
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"2Match what you see, then jump to its fix
- 1
PGROOT is not setPGROOT is not set, or points at the wrong folderFix - 2
nmake cannot be found in the prompt you are usingVisual Studio C++ support is not installed, or the wrong prompt is usedFix - 3
Access is denied (during nmake /F Makefile.win install)The install step cannot write into the PostgreSQL folderFix
- 1
What does the error look like?
PGROOT is not setAccess is deniednmake: 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.win3Verify
nmake finishes without an error message.
nmake /F Makefile.winConfirmed by raw.githubusercontent.com
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 nmake2Fix
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 nmake3Verify
nmake prints a path.
where nmakeConfirmed by raw.githubusercontent.com
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
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
Databases
Postgres cannot find the vector type for pgvector
ERROR: type "vector" does not exist
Installing pgvector on the server is not enough.
3 causes, each with a fixDatabases
DBeaver cannot run pg_restore: the utility is not found in the client home
Utility 'pg_restore' not found in client home '/usr/lib' (/usr/lib)
DBeaver runs pg_restore from a local PostgreSQL client folder; it does not bundle one.
3 causes, each with a fixDatabases
DBeaver cannot download the PostgreSQL driver from Maven
The PostgreSQL driver files are missing and the download does not complete
DBeaver downloads the PostgreSQL JDBC driver from a Maven repository the first time you connect.
3 causes, each with a fixDatabases
python manage.py migrate finishes but the tables for my app are missing
relation "myapp_book" does not exist
migrate only applies migration files that exist.
3 causes, each with a fixDatabases
Django save fails on PostgreSQL: null value in a column violates a not-null constraint
django.db.utils.IntegrityError: null value in column "price" of relation "shop_product" violates not-null constraint
A model field is NOT NULL in the database unless it has null=True.
3 causes, each with a fixDatabases
Django migration on PostgreSQL stops with 'pending trigger events'
django.db.utils.OperationalError: cannot ALTER TABLE "mytable" because it has pending trigger events
PostgreSQL runs a Django migration in one transaction.
2 causes, each with a fix