您的包被锁定为mimemagic(0.3.5),但是在您的Gemfile中列出的任何来源中都找不到该版本

今天我尝试为我的 rails 6.1.0 构建一个带有活动存储的 docker,我收到以下错误:

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.

现在我尝试安装 mimemagic

 gem install mimemagic -v 0.3.5

我有以下错误:

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

宝石好像没了。有人可以解释一下吗?

这个问题的解决方案是什么?

回答

几天前,mimemagic 版本被猛拉。可以在以下位置找到更多信息:

  • https://github.com/rails/rails/issues/41750
  • https://rubygems.org/gems/mimemagic/versions

你可以修改你的 Gemfile 如下:

gem 'mimemagic', github: 'mimemagicrb/mimemagic', ref: '01f92d86d15d85cfd0f20dabd025dcbd36a8a60f'

  • Rails 5.2.5, 6.0.3.6, and 6.1.3.1 have been released, removing the mimemagic dependency
  • 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
  • `gem 'mimemagic', '~> 0.3.10'` also worked for me.
  • 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.

回答

尝试删除 Gemfile.lock 并再次捆绑。确保您确实可以做到这一点,因为您的所有宝石都会更新。在我的 Rails 6.1 实例中,不再使用 mimemagic。完毕。

如果这是不可能的,您需要更新 mimemagic,因为他们似乎删除了 0.3.7 以下的所有版本: bundle update mimemagic

更新:我不确定它是否清楚,但 rails 不再使用 mimemagic。


回答

如果您使用的是 macOS

brew install shared-mime-info
bundle update mimemagic


以上是您的包被锁定为mimemagic(0.3.5),但是在您的Gemfile中列出的任何来源中都找不到该版本的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>