-
Notifications
You must be signed in to change notification settings - Fork 756
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bicep build
fails when run from within amd64/linux docker container on M1 Mac
#10681
Comments
Can you please provide a reproducible bicep file so we can repro the error on our end? |
Hi ellismg, this issue has been marked as stale because it was labeled as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. Thanks for contributing to bicep! 😄 🦾 |
This looks like a similar root cause to #10245. Would you mind trying to upgrade qemu (as described under "Known possible causes") and confirming whether or not that helps? |
I attempted to update the qemu version by following the docker run commands in the linked issues, but it provided no help. I also attempted to update to the latest Docker Desktop (4.20.1) and that didn't help the issue at all. However, I noticed that in the Docker Desktop changelog they mentioned that they reverted from 7.0.0 to 6.2.0 of qemu in 4.14.0 Note - I'm not 100% sure the docker commands that I ran from issues linked off of #10245 ended up actually upgrading the qemu version that Docker Desktop uses for emulation, because I don't have a great mental model of where the qemu that is being used for emulation is installed (either on the host or inside the container, and all the commands I have found linked from #10245 feel to me like they are upgrading things inside the container). To get the above stack trace I shared, I actually enabled the "Use Rosetta for x86/amd64 emulation on Apple Silicon" check box under the "Features In Development" tab of the setting pane in Docker Desktop on my mac. In this case, I don't believe that qemu is even in the mix and yet I still see issues. My reading of #10245 makes it seem like @kurt-mueller-osumc was facing the same issue and also using Rosetta, not qemu for emulation. Happy to try more things, but I am unfortunately not a Docker Desktop on macOS expert. To answer, @stephaniezyen's question, as I called out in my repo steps, this crash happens even on a completely blank I did verify that when running the same steps but using a native arm container things work as expected. I do expect that the root cause here is some issue in .NET 7, not bicep, since things were working fine in If there's some easy way to build HEAD using .NET 6, I'm happy to try that, but looking at #8963 where you adopted .NET 7.0 it was not obvious to me that there would be a quick way for me to build HEAD with .NET 6 when it landed, and I'm sure that since then you've adopted more .NET 7.0 features. |
I think switching the current HEAD back to .NET 6 may be tricky, but a quick way to prove your hypothesis could be to try and repro with the commit immediately before and after #8963 was merged. I'm not sure how comfortable you are with C#, but another possibility for trying to get a minimal repro could be creating a .NET 7 project with something like the following (basically a copy+paste of the code that's throwing): https://dotnetfiddle.net/OAWLxC using System.Text.RegularExpressions;
public class Program
{
private const string TypeSegmentPattern = "[a-z0-9][a-z0-9-.]*";
private const string VersionPattern = "[a-z0-9][a-z0-9-]+";
private const RegexOptions PatternRegexOptions = RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture | RegexOptions.Compiled | RegexOptions.CultureInvariant;
private static readonly Regex ResourceTypePattern = new Regex(@$"^(?<type>{TypeSegmentPattern})(/(?<type>{TypeSegmentPattern}))*(@(?<version>{VersionPattern}))?$", PatternRegexOptions);
public static void Main()
{
ResourceTypePattern.Match("Microsoft.Compute/virtualMachines@2022-01-01");
}
} |
Hi @ellismg, this issue has been marked as stale because it was labeled as requiring author feedback but has not had any activity for 7 days. It will be closed if no further activity occurs within 3 days of this comment. Thanks for contributing to bicep! 😄 🦾 |
Bicep version
Bicep CLI version 0.17.1 (d423d61)
Describe the bug
When trying to run
bicep build <path-to-a-bicep-file> --stdout
from within a linux docker container running on an M1 mac, there's a null reference exception during what appears to be initialization of bicep itself.Strangely the null reference looks to be coming from within the .NET Core Runtime itself. Also, other, simpler gestures, eg
bicep --version
work fine.To Reproduce
Steps to reproduce the behavior:
The simplest way I've found to reproduce this behavior is to do the following:
docker run -it --platform linux/amd64 mcr.microsoft.com/devcontainers/base:bullseye
to launch and amd64 container running on Mac.curl -OL https://github.com/Azure/bicep/releases/download/v0.17.1/bicep-linux-x64
Additional context
Instead of the stack trace I showed above, you might instead see this error:
I was getting this before I told docker to use Rosetta for x86/amd64 emulation on Apple Silicon (something you can configure with the Features In Development page in the Settings part of the Docker Desktop app)
It's possible this is related to #10245, but that was focused on the language server and this is related to just running the bicep CLI directly.
From the stack trace, it's not obvious that this is a bicep issue and not some underlying runtime issue and dotnet/runtime#78340 shows a similar shape of issue with regex weirdness on amd64 when run via an emulator, but I figured I'd open an issue here for folks that stumble upon this via bicep.
I also saw this in 0.16.1 and 0.16.2, so it's not a recent regression.
I suspect that the issue may be tied to the move to using .NET 7. If I pick up v0.14.85, which from my reading of the Git history was the last version built using .NET 6.0, things work fine. If I move to v0.15.31, then I start to see this failure (and that looks like the first official release after adopting .NET 7.0)
The text was updated successfully, but these errors were encountered: