lukka / run-cmake

GitHub Action to build C++ applications with CMake (CMakePresets.json), Ninja and vcpkg on GitHub.
MIT License
176 stars 19 forks source link

Changes in environment variables #8

Closed magnesj closed 4 years ago

magnesj commented 4 years ago

Hi,

We have been using parts of your build system, and we find it easy to use and maintain. Last week, GitHub updated the CI servers, and our build started to break. The reason was that the path to Python executable was no longer available.

It seems to me that the propagation of path from the CI server to the build process in Visual Studio is not working as expected now.

Here is a reference to a build that ran without issues before the upgrade last week. As you can see, python is no longer available from the build job in Visual Studio.

Failing build https://github.com/OPM/ResInsight/runs/536161809?check_suite_focus=true

Successful build https://github.com/OPM/ResInsight/runs/533332280?check_suite_focus=true

As a workaround we will use command line config of CMake directly.

Any clue why this happens?

Regards Magne

lukka commented 4 years ago

I just released v1 version of run-cmake and run-vcpkg, they spawn any process (e.g. cmake/git/vcpkg) under the default shell, this may help in fixing this. To understand exactly what the issue is I usually set ACTIONS_STEP_DEBUG to true in the secrets of the repository (under Settings) and then I can follow and trace the whole execution.

I started such build with full debug output on my fork in ci_actions_v1 branch where I use the v1 version of the actions. I will take a look at the log to understand how to fix it (if not fixed already).

lukka commented 4 years ago

@magnesj the build failed again in the same way. CMake is started with the following PATH env var:

PATH=[cut....] 
C:\\hostedtoolcache\\windows\\**Python**\\**3.7.6**\\x64\\Scripts;
C:\\hostedtoolcache\\windows\\**Python**\\**3.7.6**\\x64;
[....]

is that the expected path for Python? I have not spot what is possibly wrong yet.

magnesj commented 4 years ago

@magnesj the build failed again in the same way. CMake is started with the following PATH env var:

PATH=[cut....] 
C:\\hostedtoolcache\\windows\\**Python**\\**3.7.6**\\x64\\Scripts;
C:\\hostedtoolcache\\windows\\**Python**\\**3.7.6**\\x64;
[....]

is that the expected path for Python? I have not spot what is possibly wrong yet.

I think this path is correct, but I do not understand how this path is different for the job launching python.

lukka commented 4 years ago

Found the culprit: since VS 16.5, the Microsoft.Cpp.Default.props property file contains a rule that says "strip PATH to bare minimum when running inside a Developer Command Prompt of Visual Studio". This is happening when using run-cmake because when running CMake.exe on Windows the action setups the shell environment as the DevCmdPrompt would set it up.

The MSBuild rule is inside Microsoft.Cpp.Default.props: <PATH Condition="'$(__VSCMD_PREINIT_PATH)' != ''">$(__VSCMD_PREINIT_PATH)</PATH>.

There are various fixes/workaround here for run-cmake:

For consumers of run-cmake: