msys2 / msys2/msys2-runtime

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

Open
#155 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
240
Forks
60
Avg merge
2d 3h
Merged PRs (30d)
1

Description

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?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the linked msys2-runtime issues 152 and 150 and MSYS2-packages issue 3605, then reproduce the env output and the two CMake commands shown here. Trace how !:: and !C: are imported or handled and how that affects the reported /C/msys64/.../C:/... path. Done means the variables and path failure are explained, with a confirmed workaround or fix scope.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, cmake
Domain
build-system, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.