-
Notifications
You must be signed in to change notification settings - Fork 21
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
native lib for M1 Mac os #46
Comments
Yes. You can create PR with our own build. All available RIDS: See runtimes directory https://github.com/hey-red/Mime/tree/master/src/Mime/runtimes |
Here you go #47 If there is something else you want me to test out, let me know. |
@bdurrani Nuget package has been updated(version 3.5.0). Try it with some test app, to make sure the library is correctly selected according current runtime. |
I tried the following code snippet var result = MimeGuesser.GuessExtension("diamond.png");
Console.WriteLine(result); Things continue to work on a mac x64 os. On an M1, I get the following runtime error Unhandled exception. HeyRed.Mime.MagicException: Could not find any valid magic files!
at HeyRed.Mime.Magic..ctor(MagicOpenFlags flags, String dbPath)
at HeyRed.Mime.MimeGuesser.GuessMimeType(String filePath)
at HeyRed.Mime.MimeGuesser.GuessExtension(String filePath)
at Program.<Main>$(String[] args) in /Users/bilal.durrani/deletethis/ConsoleApp30/ConsoleApp30/Program.cs:line 7 Not sure what's I missed here. However, if I run this via the at 22:07:11 ❯ dotnet run -r osx.13-arm64
/usr/local/share/dotnet/sdk/7.0.200/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(1142,5): warning NETSDK1179: One of '--self-contained' or '--no-self-contained' options are required when '--runtime' is used. [/Users/bilal.durrani/deletethis/ConsoleApp30/ConsoleApp30/ConsoleApp30.csproj]
png I guess I need to figure out how to set this runtime option when running it via Rider/Visual Studio |
Look like I needed to add the RID to the csproj <PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RuntimeIdentifier>osx.13-arm64</RuntimeIdentifier>
</PropertyGroup> |
@bdurrani As temporary solution you can set database path: |
Thanks for digging into this. I will check it out. |
Well. That's quick and dirty solution but it should work. |
That seems to work. On an M1, using a console app with no configuration changes, I was able to use v3.5.1 just by adding the nuget package and hitting run, with the same code snippet as above. I realized I forgot to update the readme to mention support for Ventura arm64. |
Sigh, I also just realized. I was testing this using .NET 7. Apprently that RID was added only for .NET 7 for .NET 6, the osx RID stops at 12. it seems I wonder if you used a lower RID, whether it will also work for .NET 6 applications The following is the file i found for .NET 7 Based on this, it looks like if you specify a lower RID, things should work? |
@bdurrani |
Yeah, i figured the lib was tied to the os. UnfortunatelyI dont have access to mac os 11/12 so I can't build the libs for the other versions of mac os. This is the output from my current system. at 20:06:08 ➜ otool -L libmagic-1.dylib
libmagic-1.dylib:
/usr/local/lib/libmagic.1.dylib (compatibility version 2.0.0, current version 2.0.0)
/usr/lib/liblzma.5.dylib (compatibility version 6.0.0, current version 6.3.0)
/usr/lib/libbz2.1.0.dylib (compatibility version 1.0.0, current version 1.0.8)
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1319.0.0) Probably best to leave things as is. |
Well. I changed osx arm64 RID to more generic. If someone wants to use it on older version then we will know.
Maybe I'm missing something but why dylib from nuget has link to local libmagic?
This happens only for libraries with native dependencies. Other things should works as expected. Also, I planned to update libmagic to latest version(may be on next week) and for more consistency, configuration for native libs shoulds disable all compressing libs. |
Weird... at 15:22:13 ➜ otool -L ./libmagic-1.dylib
./libmagic-1.dylib:
/usr/local/lib/libmagic.1.dylib (compatibility version 2.0.0, current version 2.0.0)
/usr/lib/liblzma.5.dylib (compatibility version 6.0.0, current version 6.3.0)
/usr/lib/libbz2.1.0.dylib (compatibility version 1.0.0, current version 1.0.8)
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1319.0.0)
runtimes/osx-arm64/native
at 15:22:14 ➜ ls /usr/local/lib/libmagic.1.dylib
lsd: /usr/local/lib/libmagic.1.dylib: No such file or directory (os error 2). |
Ok. Maybe it's normal for Mac. On linux build I get this
|
Hi there
Would you be able to add support for m1 mac os? Seems like you would need an arm64 native lib.
I can help out if needed, but I would need some guidance on how to manage the default platform. As the default platform for mac os will no longer be x64.
I was able to get all the tests passing with a local build of libmagic v5.41, so it looks like no other code changes are required. Just needs another platform added.
I couldn't figure out how to get the dylib from the older version of brew (the newer one is too new), so I built it from source from here
https://astron.com/pub/file/
Thanks for your project.
The text was updated successfully, but these errors were encountered: