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

cha*_* ly 47 ruby-on-rails ruby-on-rails-6 mimemagic

今天我尝试为我的 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.
Run Code Online (Sandbox Code Playgroud)

现在我尝试安装 mimemagic

 gem install mimemagic -v 0.3.5
Run Code Online (Sandbox Code Playgroud)

我有以下错误:

ERROR:  Could not find a valid gem 'mimemagic' (= 0.3.5) in any repository
ERROR:  Possible alternatives: mimemagic
Run Code Online (Sandbox Code Playgroud)

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

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

小智 91

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

你可以修改你的 Gemfile 如下:

gem 'mimemagic', github: 'mimemagicrb/mimemagic', ref: '01f92d86d15d85cfd0f20dabd025dcbd36a8a60f'
Run Code Online (Sandbox Code Playgroud)

  • Rails 5.2.5、6.0.3.6 和 6.1.3.1 已发布,删除了 mimemagic 依赖项 (18认同)
  • 这个答案应该被接受:它有效,提供了修复的语法、根本原因的解释以及到背景上下文的链接。做得很好 (5认同)
  • `gem 'mimemagic', '~> 0.3.10'` 也对我有用。 (4认同)
  • 不确定创建此答案的时间,但我相信现在有比链接到特定提交更好的方法。我升级到“mimemagic-0.4.3”,但“0.3.7”、“0.3.8”、“0.3.9”、“0.3.10”也应该可以工作。 (2认同)

Pau*_*reu 22

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

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

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

  • 删除 `Gemfile.lock` 解决了我的问题 (4认同)
  • 删除 Gemfile.lock 对我有用感谢@FedericoCapaldo (2认同)

hon*_*ney 13

如果您使用的是 macOS

brew install shared-mime-info
bundle update mimemagic
Run Code Online (Sandbox Code Playgroud)

  • 没有解释原因,但需要“shared-mime-info”来修复与本机扩展相关的任何更新失败。 (2认同)