When installing ruby gems for a new project I get the following error on my M1 MacBook.

Could not find MIME type database in the following
locations: ["/usr/local/share/mime/packages/freedesktop.org.xml",
"/opt/local/share/mime/packages/freedesktop.org.xml", "/usr/share/mime/packages/freedesktop.org.xml"]

After some Googling, there are 2 solutions to solve this error.

Manually Copy & Paste File freedesktop.org.xml

First, create a file named freedesktop.org.xml, copy the file content found from Freedesktop and save it to freedesktop.org.xml.

Second, set the FREEDESKTOP_MIME_TYPES_PATH environment variable.

export FREEDESKTOP_MIME_TYPES_PATH=/path/to/freedesktop.org.xml

Install Dependency via Homebrew

Alternatively, if Homebrew is installed on your M1 Macbook, just run brew install shared-mime-info.