Skip to content

devenv: Escape spaces when relocating pkg-config prefixes - #10589

Merged
kovidgoyal merged 1 commit into
kovidgoyal:masterfrom
Saadanjum0:fix/devenv-pkgconfig-space-in-path
Oct 2, 2026
Merged

kovidgoyal merged 1 commit into
kovidgoyal:masterfrom
Saadanjum0:fix/devenv-pkgconfig-space-in-path

Conversation

@Saadanjum0

Copy link
Copy Markdown
Contributor

What

relocate_pkgconfig() writes the real, absolute dependency path into
the downloaded .pc files with a plain byte substitution. pkg-config
tokenizes Cflags/Libs on unescaped whitespace, so when the checkout
lives under a path containing a space (e.g. ~/Desktop/My Projects/kitty)
the -I/-L flags it emits get truncated at the first space and the
build fails, typically with:

kitty/state.h:16:10: fatal error: 'hb.h' file not found

even though harfbuzz's headers are right there on disk.

Fix

Backslash-escape spaces (and literal backslashes) in the new prefix
before substituting it into a .pc file, so pkg-config round-trips the
path correctly. The same function is also used to relocate the prefix
baked into _sysconfigdata_*.py, which is a plain Python string literal
rather than something pkg-config tokenizes, so that case is deliberately
left unescaped.

Testing

Added bypy/devenv_test.go, which fails on master and passes with this
change: it asserts a space in the new prefix is escaped for .pc files
and left untouched for _sysconfigdata_*.py.

I also reproduced this end to end: with a checkout path containing a
space, ./dev.sh build failed with the hb.h error above on master,
and succeeded after this change (all 89 C files compiled and linked).
The new regression test (bypy/devenv_test.go) passes; gofmt and
go vet are clean.

Likely the cause of #8939: the reporter's checkout was under
"3. Ressources" and the -I flags in that log are truncated at the
space.

relocate_pkgconfig() substitutes the real, absolute dependency path into
the downloaded .pc files by plain byte replacement. pkg-config tokenizes
Cflags/Libs on unescaped whitespace, so when that path contains a space
(for example a checkout under "Desktop/My Projects/kitty") the emitted
-I/-L flags get truncated at the first space and the build fails with
errors like "hb.h file not found", even though the dependency is right
there on disk.

Escape spaces (and literal backslashes) in the new prefix before writing
it into a .pc file so pkg-config round-trips it correctly. The same
function also relocates paths inside _sysconfigdata_*.py, which is a
plain Python string rather than something pkg-config parses, so that case
is left unescaped.

Likely the cause of #8939: the reporter's checkout was under
"3. Ressources" and the -I flags in that log are truncated at the space.
@kovidgoyal
kovidgoyal merged commit 852fef3 into kovidgoyal:master Oct 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants