hey-red / Mime

.NET wrapper for libmagic
MIT License
84 stars 22 forks source link

libmagic dependency mismatch on MacOS Monterey (5.41) #43

Closed luke-h1 closed 2 years ago

luke-h1 commented 2 years ago

Hey, Currently, I am getting the following exception in my application (c# Azure function) when using Mime due to a mismatch of dependencies (I think):

Exception:

Mime: File 5.41 supports only version 16 magic files. `/bin/output/bin/magic.mgc' is version 14.

This is what I ran when installing libmagic:

brew install libmagic
brew link libmagic
env ARCHFLAGS="-arch x86_64" gem install ruby-filemagic -- --with-magic-include=/usr/local/include --with-magic-lib=/usr/local/lib/

This happened on a 64bit Intel Mac running Monterey. The Azure function is running on the following Mime version: 3.0.0

Have you come across this issue before and if so is there a solution?

hey-red commented 2 years ago

Seems like you are install latest version of libmagic from homebrew(but why?). Do you need a fresh version of database file. It's can be taken from here:

https://github.com/hey-red/Mime/blob/master/src/Mime/content/magic.mgc

or maybe inside installation directory

/usr/local/include

then set path to this file MimeGuesser.MagicFilePath = "/path/to/magic.mgc";

luke-h1 commented 2 years ago

Hi, it turns out the solution was to simply install ruby-libmagic from https://rubygems.org/gems/libmagic. Once I installed this, I no longer get the exception:

Mime: File 5.41 supports only version 16 magic files. `/bin/output/bin/magic.mgc' is version 14.

Thanks for the help!