Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

env reporting environment variables starting with exclamation mark (possible path problems)? #155

Open
sdbbs opened this issue May 29, 2023 · 1 comment

Comments

@sdbbs
Copy link

sdbbs commented May 29, 2023

To keep the long story short: I am generally a happy user of MINGW64 and MSYS2, and try to regularly keep updated. Eventually, I wanted to refresh a project I'm building using CMake - and suddenly, it started failing. It appeared to me that it is trying to build in some wrong directories, so I decided to check env - and I saw some variables I've never seen before:

$ env
ProgramFiles(x86)=C:\Program Files (x86)
!::=::\
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
!C:=C:\Users\user\Desktop
...

I really don't understand how can a variable name be named !:: or !C: - the !C: one seems to be related to the folder where the MSYS2/MINGW64 was first started. I cannot even echo the content of these variables, and I cannot unset them; interestingly export -p does not report them.

I tried asking in https://stackoverflow.com/questions/76355596/env-reporting-environment-variables-starting-with-exclamation-mark-msys2-mingw6 but I doubt I'll get an answer there. In any case, I cannot recall ever seeing these "exclamation mark"-named environment variables ever, so I guess this is something recent. And the only reports I found, that I thought might be somewhat related, are:

Anyways - does anyone have any idea what do the !:: and !C: environment variables mean, and whether I could somehow unset them?

Btw, in my CMake project that is failing, if I call my "Windows" CMake install, like this:

$ /c/Program\ Files/CMake/bin/cmake.exe --version | head -n1
cmake version 3.14.3

$ /c/Program\ Files/CMake/bin/cmake.exe  ../ -DCMAKE_BUILD_TYPE=Debug -G "MSYS Makefiles"

... then most of my project builds, apart from one of the final targets (and it used to build fine in this setup a couple of months ago).

If I instead use the MINGW64 cmake:

$ cmake --version | head -n1
cmake version 3.26.4

$ cmake.exe  ../ -DCMAKE_BUILD_TYPE=Debug -G "MSYS Makefiles"

... then make fails almost immediately with the following (and it used to build fine also in this setup a couple of months ago):

/C/msys64/usr/bin/python3.11.exe: can't open file '/c/src/my_project/build/pico-sdk/src/rp2_common/boot_stage2/C:/src/rp2040_pico/pico-sdk/src/rp2_common/boot_stage2/pad_checksum': [Errno 2] No such file or directory

At least, I can tell that /C/msys64/.../C:/src/... is under no circumstance a valid path.

Is it possible, that these "exclamation-mark-named" environment variables !:: and !C: mess up path calculation as used the bash and/or CMake ...? Any ideas how do I get my build system working again?

@dg0yt
Copy link

dg0yt commented Oct 25, 2023

Anyways - does anyone have any idea what do the !:: and !C: environment variables mean, and whether I could somehow unset them?

I happened to stumble over this today:

/* See if environment variable is "special" in a Windows sense.
Under NT, the current directories for visited drives are stored
as =C:=\bar. Cygwin converts the '=' to '!' for hopefully obvious
reasons. We need to convert it back when building the envblock */
if (s[0] == L'!' && (iswdrive (s + 1) || (s[1] == L':' && s[2] == L':'))
&& s[3] == L'=')
*s = L'=';

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

No branches or pull requests

2 participants