91

Today I tried to build a docker for my rails 6.1.0 with active storage, I got the following error:

Your bundle is locked to mimemagic (0.3.5), but that version could not be found in any of the sources listed in your Gemfile. If you haven't changed sources, that means the author of mimemagic (0.3.5) has removed it. You'll need to update your
bundle to a version other than mimemagic (0.3.5) that hasn't been removed in order to install.

And now I try to install the mimemagic

 gem install mimemagic -v 0.3.5

I've got the following error:

ERROR:  Could not find a valid gem 'mimemagic' (= 0.3.5) in any repository
ERROR:  Possible alternatives: mimemagic

It seems like the gem is gone. Can someone explain this?

what can be the solution to this issue?

channa ly
  • 9,479
  • 14
  • 53
  • 86

3 Answers3

161

Few days ago, the mimemagic versions were yanked. More info can be found at:

You can modify your Gemfile as below:

gem 'mimemagic', github: 'mimemagicrb/mimemagic', ref: '01f92d86d15d85cfd0f20dabd025dcbd36a8a60f'
  • 7
    this answer should be accepted: it works, provides both the syntax for the fix, explanation of root cause, and link to background context. nicely done – 333kenshin Apr 02 '21 at 20:56
  • 1
    In fact the solution is to remove the mimemagic dependency, updating the gems. Rails no longer uses mimemagic because of the GPL 2 licence. – Paulo Abreu Apr 06 '21 at 08:45
  • 8
    `gem 'mimemagic', '~> 0.3.10'` also worked for me. – Daniel Harvey Apr 09 '21 at 17:26
  • 27
    Rails 5.2.5, 6.0.3.6, and 6.1.3.1 have been released, removing the mimemagic dependency – Ben Apr 14 '21 at 02:28
  • 4
    Not sure about the time this answer was created, but I believe there are better ways now than to link to a specific commit. I upgraded to `mimemagic-0.4.3`, but `0.3.7`, `0.3.8`, `0.3.9`, `0.3.10` should also work. – x-yuri Apr 21 '21 at 08:21
  • It worked for me on Rails 5.2 – alexventuraio May 19 '21 at 01:46
  • @Ben, is correct, upgrade to a new rails version, https://weblog.rubyonrails.org/2021/3/26/marcel-upgrade-releases/ – user2012677 May 21 '21 at 11:11
  • I know it's not the best place to complain, but my god I just wanted to update a text label in a code I haven't touched for years, and need to find missing gems to fix deployment. Where did we go wrong... – fantactuka May 28 '21 at 20:16
  • For people looking for the value of `ref` for some other yanked version, plz go to [MimeMagic Commit History](https://github.com/mimemagicrb/mimemagic/commits/master) and search for the commit with your version number. – Shubham Jun 09 '21 at 09:17
  • Spent my days facing with this problem on my new server, thanks a lot. Worked for me! – Baran Yeni Aug 04 '21 at 21:32
55

Try to remove the Gemfile.lock and bundle again. Make sure you can actually do that because all your gems will be updated. In my Rails 6.1 instances, mimemagic is no longer used. Done.

If that is not possible, you need to update mimemagic as it seems they removed all versions below 0.3.7: bundle update mimemagic

Update: I'm not sure if it's clear, but rails no longer use mimemagic.

Paulo Abreu
  • 1,716
  • 11
  • 16
17

If you are using macOS

brew install shared-mime-info
bundle update mimemagic
honey
  • 981
  • 6
  • 19
  • 2
    didn't explain why, but `shared-mime-info` would be needed to fix any update failures related to native extensions. – ross_troha Apr 22 '21 at 22:22
  • 1
    tried `brew install shared-mime-info` but it is a pretty long install operation. I would recommend reading this, and just upgrading and removing the dependency.... https://weblog.rubyonrails.org/2021/3/26/marcel-upgrade-releases/ – user2012677 May 21 '21 at 11:10