PKG_CONFIG_PATH not exported from windows to msys2
See original GitHub issueThis is a new error that I’m getting in GitHub CI. It started about 2 weeks ago. Seems like cygpath might be provided by git for windows, which I have never explicitly installed… Maybe GitHub changed something about their environment and cygpath is no longer in there?
/usr/bin/bash: line 1: cygpath: command not found
/usr/bin/bash: line 1: source: filename argument required
source: usage: source filename [arguments]
Error: Process completed with exit code 1.
Issue Analytics
- State:
- Created 2 years ago
- Comments:13 (2 by maintainers)
Top Results From Across the Web
Msys2 in windows 10 with GTK return error pkg-config
The PKG_CONFIG_PATH was definitely exported correctly and its path was also correct but pkg-config would stubbornly search in its default search ...
Read more >143 Pkg-config see less libraries with windows path that unix ...
Private: No. In the shell environment PKG_CONFIG_PATH equals to /mingw64/lib/pkgconfig:/mingw64/share/pkgconfig. When pkg-config called from ...
Read more >FindPkgConfig: format of PKG_CONFIG_PATH on msys2 and ...
I think all environment pathes are converted to Windows pathes when run on Windows. This may or not be a general issue of...
Read more >Python - MSYS2
Python. Since the official CPython implementation doesn't support building with GCC/Clang on Windows and has its own Windows specific directory layout, ...
Read more >Guide to pkg-config - FreeDesktop.Org
This choice is not necessary; the .pc file should simply be a unique ... found $ export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig $ pkg-config --modversion ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@eine Okay, I found a solution to my problem. I’ll describe it here and the different things that I tried. Hopefully it will save someone time in the future. If you don’t have time to read it, here’s the trick: Use
~/.bash_profile
instead of$GITHUB_ENV
for everything.Problem
Attempt 1: $GITHUB_ENV
We want to use a single GitHub CI for all builds, macos, Windows, and Ubuntu. This makes our CI smaller and more manageable. macos and unix are pretty easy because they are mostly compatible but Windows is a little trickier, especially about the environment variables! The issue is that if you put something like this in your CI:
It will set the variable in the environments for macos and for ubuntu, but it won’t work the same for Windows. That’s because it is setting the environment variable in the windows environment, which is, like the powershell. But you want the environment variable set inside of msys2.
Attempt 2: path-type: inherit
The solution should be to use
path-type: inherit
. You can read about how it works. If you look at the code for it here and here, you’ll see that inherit only affectsPATH
and not other things that you might set, likePKG_CONFIG_PATH
. That’s a bummer because we’d like those to work, too.Attempt 3: source a different file
One solution would be to instead write to a different file, maybe called
~/my_env
and then source it at each command. So you would need to modify every single command in your CI file to have asource
line at the top. Like this:That’s annoying! We don’t want to have to do that.
Attempt 4: source it in the shell
GitHub will let you change the shell command for your platform. So you might try something like this:
Now it should source your file before running the shell each time. I tried that but it didn’t work. GitHub was complaining that
source
wasn’t an executable file on the disk. That’s true, source is a command that bash know about, it’s not a file that can be executed.Attempt 5: Put it in .bashrc
We know that bash will always run
.bashrc
before it starts. So we could just put the lines that we want in.bashrc
. However, one problem:.bashrc
is only run for interactive shells. This is described in the man page for bash:So we need to make bash interactive. So we need to modify the shell to be interactive.
This causes other problems, though, because if the shell is interactive then some of the stuff that you do in your CI will behave differently and your tests will fail in a weird way. So this is no good.
Attempt 6: Put it in .bash_login.
~/.bash_login
is run only for login shells. And we can fake that by runningbash
with a-l
. So that’s a good technique for us!Solution
So in the end, here’s what the CI script could looks like:
What this does is:
os
is one ofubuntu
,windows
, andmacos
. Somatrix
, if we converted it to json, would be 3 jobs, each with a different value ofos
. Here’s what the job matrix looks like in yaml:shell
variable to all elements of the matrix withos
that matches. This way, if you have an even more complex matrix with lots of rows you don’t have to attach the shell to each one. This is what we have now in yaml for our matrix.~/.bash_profile
. It starts as all comments except for a line that causes it to exit when we are not interactive. Any lines that we place after that won’t be executed because we are not interactive, so we need to remove that. Might as well just remove it all, there is nothing useful in there. (If you want to check for yourself, putcat .bash_profile
into a CI command and see it in the logs.)~/.bash_profile
. I usedexport
but I’m not totally sure if that is necessary. No harm in it anyway.That’s it! Now a single CI will work for windows and ubuntu and macos. The pcb2gcode project is using this successfully with a fairly complicated build for all three platforms and they all use the same steps, more or less.
You can see here where PATH gets special handling: https://github.com/msys2/MSYS2-packages/blob/915946a637e1f2b7e26e32782f3af322009293db/filesystem/profile#L28-L45
PKG_CONFIG_PATH does not: https://github.com/msys2/MSYS2-packages/blob/915946a637e1f2b7e26e32782f3af322009293db/filesystem/profile#L53