ninja-build/ninja

Environment variable with a hyphen is dropped in ubuntu

Open

#2288 opened on Apr 20, 2023

View on GitHub
 (3 comments) (0 reactions) (0 assignees)C++ (10,194 stars) (1,544 forks)batch import
bughelp wanted

Description

Feel free to close this as invalid, the bug is likely not in ninja, as it looks like ninja simply does a posix_spawn to launch a process without modifying the environment. Though interestingly I could not reproduce the issue without ninja (tried my own wrapper that does posix_spawn etc), so opening it here as someone else might have experienced the same issue.

populate buid.ninja with

rule environ
    command = env

build env.txt: environ

Run ninja with command:

env - FOO_bar=1 FOO_baz-baz=2 ninja

Expected output from env should include both FOO_bar and FOO_baz-baz variables, but on some systems you will only see the variable without hyphen in the name, those with hyphen are dropped somewhere.

So far I've tested: Ubuntu: Buggy Linux Mint: Buggy Fedora: Works Fine Arch: works Fine

I've also debugged by making ninja printing environ just before doing posix_spawn and I can see the variable FOO_baz-baz there, it just isn't visible in the launched process.

My guess is that ubuntu glibc does something wrong somewhere, but I couldn't find it

Contributor guide