Macbook M1 without Rosetta for C#

642 views
Skip to first unread message

JulianDev

unread,
May 27, 2023, 8:05:01 AM5/27/23
to grpc.io
Hey Guys,

Im trying to use gRPC for C# on my Macbook M1 with Rider.

Currently I have this error.

Google.Protobuf.Tools.targets(292, 5): [MSB6003] The specified task executable "/Users/julian/.nuget/packages/grpc.tools/2.53.0/tools/macosx_x64/protoc" could not be run. System.ComponentModel.Win32Exception (86): An error occurred trying to start process '/Users/julian/.nuget/packages/grpc.tools/2.53.0/tools/macosx_x64/protoc' with working directory '/GrpcService1'. Bad CPU type in executable
   at System.Diagnostics.Process.ForkAndExecProcess(ProcessStartInfo startInfo, String resolvedFilename, String[] argv, String[] envp, String cwd, Boolean setCredentials, UInt32 userId, UInt32 groupId, UInt32[] groups, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean usesTerminal, Boolean throwOnNoExec)
   at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start()
   at Microsoft.Build.Utilities.ToolTask.ExecuteTool(String pathToTool, String responseFileCommands, String commandLineCommands)
   at Microsoft.Build.Utilities.ToolTask.Execute()

Is there any way to change it so I can use the protoc and grpc_csharp_plugin I installed via brew?
I tried setting environment variables and then tried to build it with dotnet build, that worked, but still no code was generated which can be used in C#.

Kind regards :)

Игорь Букач

unread,
Jun 13, 2023, 7:10:06 AM6/13/23
to grpc.io
softwareupdate --install-rosetta

суббота, 27 мая 2023 г. в 15:05:01 UTC+3, JulianDev:

Phillip Young

unread,
Jun 21, 2023, 5:30:39 AM6/21/23
to grpc.io
So I guess all latest Mac users now have this issue.

I have created a dotnet grpc project using the in-built template. The nuget packages don't support the M* architecture and it definitely tries to use the x86 version. Now, it is possible to use the latest grpc.tools via brew (which supports M*) by swapping out in the package using symlinks. The issue though is that I'm not actually sure which variant of grpc is being targeted by the brew version. In the templated example, a greet.proto is provided. If I protoc (using the brew version) the resultant .cs file is not compatible with the rest of the example codebase. I suspect that is targeting the deprecated c# support rather than the newer dotnet-grpc?

Any information provided would be good!
Thanks,
Phillip

Jan Tattermusch

unread,
Jun 26, 2023, 5:41:40 AM6/26/23
to grpc.io
Starting from Grpc.Tools 2.38, you should be able to run the protoc codegen via rosetta (The platform autodetection in Grpc.Tools automatically uses x64 binary instead of the missing arm64 binary).


As suggested above, you need to have rosetta installed. 
Reply all
Reply to author
Forward
0 new messages