question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Errors while trying to run this using .NET 6 arm64 SDK with M1 Macbook Pro

See original GitHub issue

Description

Im getting an error when trying to use this inside .net 6 web project on M1 macbook pro (arm64 architecture). The error is: System.DllNotFoundException: Failed to load the librdkafka native library. at Confluent.Kafka.Impl.Librdkafka.TrySetDelegates(List1 nativeMethodCandidateTypes) at Confluent.Kafka.Impl.Librdkafka.LoadOSXDelegates(String userSpecifiedPath) at Confluent.Kafka.Impl.Librdkafka.Initialize(String userSpecifiedPath) at Confluent.Kafka.Consumer2…ctor(ConsumerBuilder2 builder) at Confluent.Kafka.ConsumerBuilder2.Build()

It works if i run the project on older .net5 using rosetta, without any code change. If i update to .net6 and use arm, it gives this error on first consumer/producer usage. I have tried side loading the library from “brew install librdkafka” using Library.Load, but no success there. Any chance to get it to work on .net 6, or is it not supported yet?

How to reproduce

I think description says it all, just try to install only .net6 sdk on m1 macbook and try to run this nuget

Checklist

Please provide the following information:

  • [x ] A complete (i.e. we can run it), minimal program demonstrating the problem. No need to supply a project file.
  • [ 1.8.2] Confluent.Kafka nuget version.
  • [1.8.2] Apache Kafka version.
  • [ x] Client configuration.
  • [ MacOs Monterey] Operating system.
  • [description ] Provide logs (with “debug” : “…” as necessary in configuration).
  • [ x] Provide broker log excerpts.
  • [ for me, yes, for others, probably not so critical] Critical issue.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:8
  • Comments:12 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
k-kapsazovcommented, Feb 18, 2022

Hi @vijaybw , The files you need are:

librdkafka++.1.dylib
librdkafka++.dylib
librdkafka.a
librdkafka++.a
librdkafka.1.dylib
librdkafka.dylib

After you add them to your project the file structure should look like this: image

Don’t forget to mark all added files as “Content” and “Copy always” in your IDE. In Rider or Visual Studio that is done by right click on given file > Properties > options “Build action” and “Copy to output directory”.

That is all you need. Now when you build the project librdkafka should work.

6reactions
k-kapsazovcommented, Feb 14, 2022

Hi, The other day my team hit the same problem. After some digging in the code we found the actual error is:

Unable to load shared library 'librdkafka' or one of its dependencies. In order to help diagnose loading problems, 
consider setting the DYLD_PRINT_LIBRARIES environment variable:
 dlopen(liblibrdkafka, 0x0001): tried: 'liblibrdkafka' (no such file), 
 '/usr/local/lib/liblibrdkafka' (no such file), 
 '/usr/lib/liblibrdkafka' (no such file), 
 '/Users/<your user>/<your project>/bin/Debug/net6.0/liblibrdkafka' (no such file), 
 '/usr/local/lib/liblibrdkafka' (no such file), 
 '/usr/lib/liblibrdkafka' (no such file)

So we concluded that the actual package is missing from the right place.

So as a workaround you can do the following:

  1. run command brew install librdkafka

  2. copy all files from /opt/homebrew/Cellar/librdkafka/1.8.2/lib to one of the suggested location in the error (We choose the directory of the project ‘/Users/(your user)/(your project)’)

  3. mark all added files as “Content” and “Copy always” in your IDE so they get transferred to the /bin/Debug folder on build (if you choose one of the other locations this is not needed)

  4. after build everything should work without an error

PS: We tried setting the working directory of librdkafka with the line Library.Load("/opt/homebrew/Cellar/librdkafka/1.8.2/lib") but it didn’t work.

Read more comments on GitHub >

github_iconTop Results From Across the Web

.NET 6 and M1 problems when other SDKs are present in ...
Run Rider, go to File | Settings | Build, Execution, Deployment | Toolset and Build and choose proper dotnet CLI (x64 or ARM...
Read more >
.net 6 SDK on M1 MacBook Pro fails to load after installing ...
I have installed the .net 6 SDK for M1 Mac / ARM64 (GA version released today) today and verified that it worked OK...
Read more >
Problem installing with dotnet on M1 MacOS architecture
Hello. I have installed : dotnet-sdk-3.1.417-osx-x64.pkg on a MAC mini M1 arm64 and I have the following issue when I run dotnet :...
Read more >
Visual Studio 2022 Mac M1 .NET 6, Could not load file or ...
I am having an issue with .NET 6 on Visual Studio 2022 Mac M1 chip. What happens is when I want to build...
Read more >
Installing .NET 6 on your M1 Mac (manually) - Maarten Merken
In this short article, I'll show you how to uninstall any previous dotnet versions on your M1 Mac and install the latest .NET...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found