Environment variables in $GITHUB_ENV ignored for PATH and PKG_CONFIG_PATH
See original GitHub issueI’m using $GITHUB_ENV
to modify environment variables. Sometimes it works, sometimes it doesn’t.
In my CI yaml file, I have this:
- name: Setup paths and env
run: |
mkdir -p $HOME/.local/bin
mkdir -p $HOME/.local/lib/pkgconfig
echo "PKG_CONFIG_PATH=$HOME/.local/lib/pkgconfig:$PKG_CONFIG_PATH" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=$HOME/.local/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV
echo "PATH=$HOME/.local/bin:$PATH" >> $GITHUB_ENV
echo "ANT_HOME=foo" >> $GITHUB_ENV
echo "ANT_HOME2=bar" >> $GITHUB_ENV
And later on in the same ci, I have this:
- name: Display information about build environment
continue-on-error: true
run: |
env
g++ --version
clang++ --version
pkg-config --version
m4 --version
The first one should put some new variables into $GITHUB_ENV
. Those variable then become part of the execution environment for the second one. We can see that it somewhat works. Here’s the log of the CI run:
2020-12-25T16:24:59.5787589Z ##[group]Run env
2020-12-25T16:24:59.5788080Z [36;1menv[0m
2020-12-25T16:24:59.5788444Z [36;1mg++ --version[0m
2020-12-25T16:24:59.5788831Z [36;1mclang++ --version[0m
2020-12-25T16:24:59.5789451Z [36;1mpkg-config --version[0m
2020-12-25T16:24:59.5789887Z [36;1mm4 --version[0m
2020-12-25T16:24:59.5792315Z shell: D:\a\_temp\msys\msys2.CMD {0}
2020-12-25T16:24:59.5792732Z env:
2020-12-25T16:24:59.5793218Z MSYSTEM: MINGW64
2020-12-25T16:24:59.5793969Z PKG_CONFIG_PATH: /home/runneradmin/.local/lib/pkgconfig:/mingw64/lib/pkgconfig:/mingw64/share/pkgconfig
2020-12-25T16:24:59.5794828Z LD_LIBRARY_PATH: /home/runneradmin/.local/lib:
2020-12-25T16:24:59.5796094Z PATH: /home/runneradmin/.local/bin:/mingw64/bin:/usr/local/bin:/usr/bin:/bin:/c/Windows/System32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0/:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
2020-12-25T16:24:59.5797320Z ANT_HOME: foo
2020-12-25T16:24:59.5797714Z ANT_HOME2: bar
2020-12-25T16:24:59.5798095Z NUM_CPUS: 8
2020-12-25T16:24:59.5798458Z ##[endgroup]
2020-12-25T16:24:59.9898476Z USERDOMAIN=fv-az177-439
2020-12-25T16:24:59.9899859Z OS=Windows_NT
2020-12-25T16:24:59.9901764Z LD_LIBRARY_PATH=/home/runneradmin/.local/lib:
2020-12-25T16:24:59.9904727Z COMMONPROGRAMFILES=C:\Program Files\Common Files
2020-12-25T16:24:59.9919605Z PROCESSOR_LEVEL=6
2020-12-25T16:24:59.9921928Z PSModulePath=C:\Modules\azurerm_2.1.0;C:\Modules\azure_2.1.0;C:\Users\packer\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\windows\system32\WindowsPowerShell\v1.0\Modules;C:\Program Files\Microsoft SQL Server\130\Tools\PowerShell\Modules\;C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\PowerShell
2020-12-25T16:25:00.0211451Z ANT_HOME2=bar
2020-12-25T16:25:00.0265443Z ANT_HOME=foo
2020-12-25T16:25:00.0272362Z PKG_CONFIG_PATH=/mingw64/lib/pkgconfig:/mingw64/share/pkgconfig
2020-12-25T16:25:00.0267298Z PATH=/mingw64/bin:/usr/local/bin:/usr/bin:/bin:/c/Windows/System32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0/:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
(I didn’t include all the lines in the above log to keep it brief. Full log here.)
Notice how the environment for this command includes setting variables like MSYSTEM
, PATH
, LD_LIBRARY_PATH
and others in the very first lines. And then when we view the results of env
, some of those were set into the environment correctly, such as ANT_HOME
and ANT_HOME2
and LD_LIBRARY_PATH
. But others, like PKG_CONFIG_PATH
and PATH
were not taken from the environment.
I expected that all the values in the environment would make it into the result of env, not just some of them.
Issue Analytics
- State:
- Created 3 years ago
- Comments:20 (1 by maintainers)
Top GitHub Comments
Please, let us know how it goes. Since this Action is very specifically to be used on GitHub Actions, I think it might make sense to add that feature into https://github.com/msys2/setup-msys2/blob/master/main.js#L164-L168 (making it optional).
@eine I never figured out what’s going on here: https://github.com/msys2/setup-msys2/issues/98#issuecomment-751411288
How come the scripts have that line added at the top and bottom. And how come msys2 is unaffected? It’s strange to me.
Do you know where I could search inside of the GitHub actions to find if those lines are being added somewhere?