Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happened to mimemagic?

What happened to mimemagic? @rails activerecord depends on @basecamp marcel which depends on mimemagic 0.3.2. Now that mimemagic 0.3.2 has been yanked, what is the way forward?

like image 343
Everistus Olumese Avatar asked Mar 24 '21 16:03

Everistus Olumese


People also ask

Could not find Mimemagic 0.3 5 in any sources?

Question: How to Solve Bundler::GemNotFound: Could not find mimemagic-0.3. 5 in any of the sources on Rails project with Docker ? Answer: bundle update –conservative mimemagic also try with newer version rather than locking it. it worked for us with 0.3.

What is mimemagic Rails?

The mimemagic software library provided a component of Rails called Active Storage with mime type data – used to identify file formats – and was initially distributed under an MIT license. But mimemagic has a dependency of its own called shared-mime-info that is distributed under the GPLv2 license.


Video Answer


6 Answers

Note: upgrading to Mimemagic 0.3.8 is still under GPL-2.0 license which may not be desirable under all circumstances.

I ran into this today and here's what I ended up doing to fix the issue
(I'm on a MBP Catalina 10.15.7)

Step 1: update Gemfile.lock to mimemagic 0.3.8 by running

  $ brew install shared-mime-info
  $ bundle update mimemagic

(Be sure the system you're deploying to has the proper libraries installed).

βœ… Mimemagic issue solved thanks to this comment

Step 2: Upgrade yarn packages
when I did this, it updated everything in homebrew so when I went to restart my server, I received the

  Your Yarn packages are out of date!
  Please run `yarn install` to update.

but, running $yarn install gave me the error:

  dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.67.dylib
  Referenced from: /usr/local/bin/node

and

  yarn check v1.22.10
  warning Integrity check: System parameters don't match
  error Integrity check failed
  error Found 1 errors.

Finally fixed yarn issues by running

   $ yarn --update-checksums

πŸŽ‰ Yarn Issue solved (thanks to this blog post )

Step 3 Last, brew also updated my Postgresql from 12 to 13.2 so I received the

  PG::ConnectionBad - could not connect to server: No such file or directory
  Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

No PID to remove, stopping and restarting, unloading and reloading, launch ctl didn't work... finally, this worked check postgres.log by running

  $ tail -n 10 /usr/local/var/log/postgres.log 

last line shows:

 FATAL:  database files are incompatible with server
 DETAIL:  The data directory was initialized by PostgreSQL version 12, which is not compatible with this version 13.2.

πŸ™ŒπŸ» Fixed with:

  $ brew postgresql-upgrade-database

Last, postgres db upgrade fixed thanks to this post

like image 121
ea0723 Avatar answered Oct 24 '22 06:10

ea0723


You can get the gem back. The gem binary built might have been removed but the commit ref of each release still there. You can ref to the gem with the github commit ref like this:

# 0.3.2
gem 'mimemagic', github: 'mimemagicrb/mimemagic', ref: '3543363026121ee28d98dfce4cb6366980c055ee'

for other commit ref you can see this link:

https://github.com/mimemagicrb/mimemagic/commits/0.3?after=22c06826417ed67c02b94ebc9998c24da5a03c56+69&branch=0.3

like image 38
channa ly Avatar answered Oct 24 '22 04:10

channa ly


Rails team has posted a patch update that remove the mimemagic dependency. The Marcel library now uses Apache Tika, released under the permissive and compatible Apache License 2.0

Read more at: https://weblog.rubyonrails.org/2021/3/26/marcel-upgrade-releases/

like image 32
Everistus Olumese Avatar answered Oct 24 '22 06:10

Everistus Olumese


The gem author has pulled all versions due the gem itself violating the GPL license requirements. Currently there's people working solutions to make a MIT compatible solution or to work around the dependencies.

Discussion: https://github.com/rails/rails/issues/41750

like image 3
codingbunny Avatar answered Oct 24 '22 06:10

codingbunny


hard coded gem reference for a workaround here

like image 1
Fdwillis Avatar answered Oct 24 '22 04:10

Fdwillis


Please install shared-mime-info and add FREEDESKTOP_MIME_TYPES_PATH in your environment. if you use windows or linux, please download from https://gitlab.freedesktop.org/xdg/shared-mime-info/uploads/0440063a2e6823a4b1a6fb2f2af8350f/shared-mime-info-2.0.tar.xz and extract it

like image 1
Phuc TC Avatar answered Oct 24 '22 04:10

Phuc TC