BobBuildTool/bob

Option -E leads to collision regarding TMP environment variables on MSYS

Closed this issue · 6 comments

When using bob dev/build with option -E (preserve environment) on MSYS with a current Bob version, e.g. 0.19.2, the following error message is thrown:

Error: Colliding environment variables: TEMP ~= temp, tmp ~= TMP

I use this option quite rarely, but in earlier Bob versions it worked fine. It seems to got broken in some of the newer versions.

From invoker.py I can see, that the corresponding sanity check complains about these two environment variables, since they exist twice, upper case and lower case.

But AFAIK this is usual on MSYS, the upper case variables TMP and TEMP provide the MSYS temporary directory and the lower case variables tmp and temp provide the Windows temporary directory.

AFAIKS the corresponding check was introduced in commit 4e488a7, when the file invoker.py was introduced.

How to deal with that situation?

IIRC the problem is that environment variables are officially case-insensitive (but case-preserving) on Windows. Interestingly there can be still variables that only differ in case. It's just not defined which one is used by the (child) process. Now it seems that cmd.com and MSYS do work partially case insensitive. This makes the sanity check kind of moot. It's there to prevented the case where the recipe defines variables that only differ in case because it's undefined which variable is read by the invoked process.

Interestingly, native Win32 Python will convert all environment variables to upper case and thus remove duplicates. I guess this is why I stumbled upon this in the first place.

All in all I would consider this a regression and we should remove the sanity check. We might still print a warning that you're about to run into undefined behaviour, though...

Possible fix in #434. Not sure if the warning is still too noisy...

Is it maybe possible to distinguish between environment variables defined inside the Bob build system and all other environment variables (system environment variables)? In this case the sanity check could be limited to Bob environment variables.

I've updated the PR. Could you try and see if it works for you?