actions / runner-images

GitHub Actions runner images
MIT License
9.22k stars 2.86k forks source link

Missing atlbase.h file in windows-2022 runner #9873

Open kanak-clumio opened 2 weeks ago

kanak-clumio commented 2 weeks ago

Description

We have a CI pipeline that stopped working from 16hrs ago. It is in a private repository and there is no code change in it for weeks.

This is the error we are getting -

fatal error C1083: Cannot open include file: 'atlbase.h': No such file or directory

It uses windows-2022 runner

worked yesterday: https://github.com/actions/runner-images/blob/win22/20240421.1/images/windows/Windows2022-Readme.md broken today: https://github.com/actions/runner-images/blob/win22/20240514.3/images/windows/Windows2022-Readme.md

Since there was no recent changes to our repository there must be some changes to the windows-2022 runner that made altbase.h no longer available when compiling I see the package name in win22/20240514.3 is Microsoft.VisualStudio.Component.VC.ATL which is different from the previous release.

We also filed an issue with microsoft for this - https://github.com/microsoft/setup-msbuild/issues/127

Platforms affected

Runner images affected

Image version and build link

Image: windows-2022 Version: 20240514.3.0 Included Software: https://github.com/actions/runner-images/blob/win22/20240514.3/images/windows/Windows2022-Readme.md Image Release: https://github.com/actions/runner-images/releases/tag/win22%2F20240514.3

Is it regression?

Yes, it was working in version 20240421.1.0

Expected behavior

We should not see 'atlbase.h' not found error.

Actual behavior

Seeing error that 'atlbase.h' file is not found.

Repro steps

Run a workflow like this and try to build any C++ Visual Studio project which imports this header file -

name: CI
on:
  push:
    branches: [ 'main', 'releases/**' ]
  pull_request:
    branches: [ '**' ]
  workflow_dispatch:
  # Allow manual trigger for debugging the workflow.
jobs:
  CI-checks:
    runs-on: windows-2022
    steps:
      - name: Disable git autocrlf
        run: git config --global core.autocrlf false

      - uses: actions/checkout@v4

      # The msbuild version is dictated by the Windows image provided by GitHub.
      - uses: microsoft/setup-msbuild@v2
      - uses: darenm/Setup-VSTest@v1.2
      - name: Build and test with Sonar Wrapper
        shell: cmd
        run: test-all.cmd
erik-bershel commented 2 weeks ago

Hey @kanak-clumio!

Take a look here, please: https://github.com/actions/runner-images/issues/9701 We excluded multiple Visual Studio 2022 VC components from the image due to a bug in VS which blocks other images users. I may recommend you to add necessary components/version in runtime using snippet:


    steps:
      - name: Delete components
        run: |
                Set-Location "C:\Program Files (x86)\Microsoft Visual Studio\Installer\"
                $InstallPath = "C:\Program Files\Microsoft Visual Studio\2022\Enterprise"
                $componentsToRemove= @(
                    "Microsoft.VisualStudio.Component.VC.ATL"
                )
                [string]$workloadArgs = $componentsToRemove | ForEach-Object {" --remove " +  $_}
                $Arguments = ('/c', "vs_installer.exe", 'modify', '--installPath', "`"$InstallPath`"",$workloadArgs, '--quiet', '--norestart', '--nocache')
                # should be run twice
                $process = Start-Process -FilePath cmd.exe -ArgumentList $Arguments -Wait -PassThru -WindowStyle Hidden
                $process = Start-Process -FilePath cmd.exe -ArgumentList $Arguments -Wait -PassThru -WindowStyle Hidden

      - name: Install components
        run: |
                Set-Location "C:\Program Files (x86)\Microsoft Visual Studio\Installer\"
                $InstallPath = "C:\Program Files\Microsoft Visual Studio\2022\Enterprise"
                $componentsToRemove= @(
                  "Microsoft.VisualStudio.Component.VC.v141.ATL"
                  "Microsoft.VisualStudio.Component.VC.14.29.16.11.ATL"
                )
                [string]$workloadArgs = $componentsToRemove | ForEach-Object {" --add " +  $_}
                $Arguments = ('/c', "vs_installer.exe", 'modify', '--installPath', "`"$InstallPath`"",$workloadArgs, '--quiet', '--norestart', '--nocache')
                # should be run twice
                $process = Start-Process -FilePath cmd.exe -ArgumentList $Arguments -Wait -PassThru -WindowStyle Hidden
                $process = Start-Process -FilePath cmd.exe -ArgumentList $Arguments -Wait -PassThru -WindowStyle Hidden
erik-bershel commented 2 weeks ago

@kanak-clumio I'll wait for your response. One version of the ATL package must contain a header file:

                  "Microsoft.VisualStudio.Component.VC.v141.ATL"
                  "Microsoft.VisualStudio.Component.VC.14.29.16.11.ATL"

I recommend reporting the bug to the Visual Studio Developer Community to understand why it was excluded in the latest version of Component.VC.ATL.

sodul commented 2 weeks ago

@erik-bershel uninstalling and re-installing the ATL component seems to fix the compilation issue but it add 5-6m to the runs. We found that the missing header is actually present on disk at:

/c/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.39.33519/atlmfc/include/atlbase.h

So we believe that it was just not installed properly and not added to the import paths of the compiler. If there is a faster way to make the existing atlbase.h discoverable that might be good enough.

erik-bershel commented 2 weeks ago

Hey @sodul!

Glad to hear that we localised bug. Appreciate your effort! Would be very nice if you report this bag to the Visual Studio so they can fix it for other users.

Same time I found a discussion on SO: https://stackoverflow.com/questions/3898287/c-include-atlbase-h-is-not-found

There were mentioned two options:

After that add additional VC++ directories in the project properties:

Include directories: C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.14.26428\atlmfc\include
Library directories: C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.14.26428\atlmfc\lib\x86
The VC++ compiler should now be able to find the ATL source and library files.
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC>mklink /d atlmfc "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\atlmfc"
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\atlmfc\lib>mklink /d amd64 "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\atlmfc\lib\x64

I am sure that the second one will definitely work if you correct a path.

erik-bershel commented 2 weeks ago

This action might be also a solution (a workaround to be honest) of the issue: https://github.com/marketplace/actions/setup-msvc-developer-command-prompt

erik-bershel commented 2 weeks ago

Hey @sodul!

This https://github.com/actions/runner-images/pull/9876 should solve your issue I think.

kanak-clumio commented 2 weeks ago

Thanks @erik-bershel for the help!

I've made a change to add the workaround you suggested of deleting and adding components so that our CI goes through. This increases the build time by 7 min but we can manage it till your above change is available in the next windows-2022 runner version.

Metadorius commented 2 weeks ago

Had the same issue today when we merged another PR in our project. https://github.com/Phobos-developers/Phobos/actions/runs/9141719975/job/25136537634

Is it possible to somehow revert to the previous runner version where it was working?

erik-bershel commented 2 weeks ago

Is it possible to somehow revert to the previous runner version where it was working?

Nope. Only to wait for the next release or to update ATL library in runtime.

provegard commented 1 week ago

Do you plan on making a release with the fix in the next few days? I'm considering if I should add the workaround to our pipeline, but if a new release is in the works, I might as well wait.

erik-bershel commented 1 week ago

Hey @provegard! We are expecting release on the very next week, but without any strict frames and promises - some blocker might happen.

provegard commented 1 week ago

Thanks @erik-bershel, good to know!

hudsy13 commented 4 days ago

Hello @erik-bershel any update on when a new 2022 runner will be released. I am encountering the same issue with the missing ATL and deciding on whether to add the code or wait for the next runner.

Thanks

erik-bershel commented 4 days ago

Hey @hudsy13! Suddenly we got some release blocker. But we are keeping hope to release Windows images ob this week.

bhanusridhar commented 3 days ago

Hi @erik-bershel, We are having our pipelines running on windows-latest image. With latest image version 20240514.3.0, we are facing issue in VSBuild task as "Error RC1015: cannot open include file 'afxres.h'".

With latest version of windows-2019 image, VSBuild task is working fine.

Will this issue also be fixed as part of the deployment.

Please feel to correct me if I am writing down in the wrong window.

erik-bershel commented 3 days ago

Hey @bhanusridhar! It seems to be a part of v142 MFC VC component which was previously removed. I'll take a look on what might be done here to eliminate this. Till possible solution it's better to install it in runtime.

bhanusridhar commented 2 days ago

@erik-bershel As it was working on windows-2019 image, we have currently mapped our pipeline to run on windows-2019 image without making any additional changes of including any installation steps.

Hoping to see it work in windows-2022 image as well. Thanks in advance!

erik-bershel commented 2 days ago

Hey @bhanusridhar! I'm a bit surprised. Header file afxres.h supposed to be a part of Microsoft.VisualStudio.Component.VC.ATLMFC which is already a part of our installation.

And it seems to be existing on disk:

Run Get-ChildItem -Path "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\" -Recurse -Filter "afxres.h" | Select-Object -ExpandProperty FullName
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.39.33519\atlmfc\include\afxres.h

May I ask you run once next code before build to check if the issue persists with the current version of library only?

      - name: Delete components
        run: |
                Set-Location "C:\Program Files (x86)\Microsoft Visual Studio\Installer\"
                $InstallPath = "C:\Program Files\Microsoft Visual Studio\2022\Enterprise"
                $componentsToRemove= @(
                    "Microsoft.VisualStudio.Component.VC.ATLMFC"
                    "Microsoft.VisualStudio.Component.VC.ATLMFC.Spectre"                   
                )
                [string]$workloadArgs = $componentsToRemove | ForEach-Object {" --remove " +  $_}
                $Arguments = ('/c', "vs_installer.exe", 'modify', '--installPath', "`"$InstallPath`"",$workloadArgs, '--quiet', '--norestart', '--nocache')
                # should be run twice
                $process = Start-Process -FilePath cmd.exe -ArgumentList $Arguments -Wait -PassThru -WindowStyle Hidden
                $process = Start-Process -FilePath cmd.exe -ArgumentList $Arguments -Wait -PassThru -WindowStyle Hidden

      - name: Install components
        run: |
                Set-Location "C:\Program Files (x86)\Microsoft Visual Studio\Installer\"
                $InstallPath = "C:\Program Files\Microsoft Visual Studio\2022\Enterprise"
                $componentsToRemove= @(
                  "Microsoft.VisualStudio.Component.VC.14.29.16.11.MFC"
                  "Microsoft.VisualStudio.Component.VC.14.29.16.11.MFC.Spectre"
                  "Microsoft.VisualStudio.Component.VC.14.29.16.11.ATL"
                  "Microsoft.VisualStudio.Component.VC.14.29.16.11.ATL.Spectre"
                )
                [string]$workloadArgs = $componentsToRemove | ForEach-Object {" --add " +  $_}
                $Arguments = ('/c', "vs_installer.exe", 'modify', '--installPath', "`"$InstallPath`"",$workloadArgs, '--quiet', '--norestart', '--nocache')
                # should be run twice
                $process = Start-Process -FilePath cmd.exe -ArgumentList $Arguments -Wait -PassThru -WindowStyle Hidden
                $process = Start-Process -FilePath cmd.exe -ArgumentList $Arguments -Wait -PassThru -WindowStyle Hidden
bhanusridhar commented 1 day ago

Hi @erik-bershel. I have tested the above. By including the above scripts before build, Build solution passed now.

So, I guess issue persists with the current version of library only.