pythonlinkergitlab-ci-runner

GitLab Runner with python setuptools not able to execute build job - kernel32.lib not found


I'm trying to get my gitlab-runner pipeline (OS: Windows10) back running, but it always fails with this error LINK : fatal error LNK1104: cannot open file 'kernel32.lib' when executing the build command of my python project.

The build command starts the build process of python's setuptools package. It creates some files but when it launches Visual Studio's link.exe it immediately fails to find the kernel32.lib.

I tried everything that I could think of. For example passing the path leading to kernel32.lib to the include_dirs of setuptools, since in the past this helped with the io.h not found error.

Also I tried different versions of the Windows SDK from the Visual Studio Installer until the point of only one Version being installed, reinstalling Visual Studio Installer and passing the path to the gitlab runners environment from it's config.toml

So here is what is really strange. If I run the commands that would normally be run by the gitlab-runner in the background (gitlab-runner shell: powershell) directly from powershell manually everything works as expected. It doesent matter if I run the gitlab runner or the powershell as administrator, the outcome is the same. It also doesn't change if I run the gitlab as a Windows service or run it in powershell or cmd

After realizing that, I compared the output of powershell with the output of gitlab's pipeline and noticed that the parameters for the link.exe are different. Specifically the path for the kernel32.lib is missing in the log of the pipeline.

Knowing that I tried some ownership changes on the related folders but with no success. It seems like that setuptools isn't finding the path and therefore not passing it to the link.exe which then ultimately causes the error

This is the current status on VS Installer (Allready tried to remove older Versions, still not working

Any help would be really great.


Solution

  • I have found some solutions for me now. Some of you would probably say that it shouldn't be done that way but I tried everything else so this was the only option.

    Opening powershell as administrator and executing the following command did the trick.

    SETX LIB 'C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.36.32532\lib\x64;C:\Program Files (x86)\Windows Kits\10\lib\10.0.22000.0\ucrt\x64;C:\Program Files (x86)\Windows Kits\10\\lib\10.0.22000.0\\um\x64'

    If you are having trouble with io.h in the same context this command could help.

    SETX INCLUDE 'C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt;C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um;C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\shared;C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\winrt;C:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\cppwinrt;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um'