【问题标题】:Bundler::GemNotFound: Could not find mimemagic-0.3.5 in any of the sources on Rails project with DockerBundler::GemNotFound:在使用 Docker 的 Rails 项目的任何源中都找不到 mimemagic-0.3.5
【发布时间】:2021-06-24 21:33:39
【问题描述】:

我知道最近的 mimemagic 问题,我设法通过捆绑更新到 0.3.7 解决了我的一个 Rails 项目 - 但由于某种原因,我无法在下面的项目中解决它。

我有一个 Rails 6 项目,我在一台新笔记本电脑上第一次设置。我的笔记本电脑没有正确的 Ruby 设置,所以我在我的项目中添加了一个 Dockerfile,如下所示:-

Dockerfile

FROM ruby:2.7
RUN apt-get update -qq && apt-get install -y nodejs postgresql-client
WORKDIR /radius
COPY Gemfile /myapp/Gemfile
COPY Gemfile.lock /myapp/Gemfile.lock
RUN bundle update mimemagic
RUN bundle install
COPY . /myapp


COPY entrypoint.sh /usr/bin/
RUN chmod +x /usr/bin/entrypoint.sh
ENTRYPOINT ["entrypoint.sh"]
EXPOSE 3000


CMD ["rails", "server", "-b", "0.0.0.0"]

宝石文件

# frozen_string_literal: true

source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '2.7.2'
gem 'airbrake'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'dotenv-rails'
gem 'rails', '~> 6.0.3.6'
# Use postgresql as the database for Active Record
gem 'pg', '>= 0.18', '< 2.0'
# Use Puma as the app server
gem 'puma', '~> 3.11'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5'
gem 'shortener'

# Use Honeybadger for error reporting/monitoring
gem 'honeybadger', '~> 4.0'
# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
gem 'webpacker', '~> 4.0'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use Active Model has_secure_password
# gem 'bcrypt', '~> 3.1.7'
gem 'newrelic_rpm'

# Use Active Storage variant
# gem 'image_processing', '~> 1.2'

# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.4.2', require: false

group :development, :test do
  gem 'awesome_print'
  gem 'byebug', platforms: %i[mri mingw x64_mingw]
  gem 'pry-byebug'
  # Version specified as workaround for this issue https://github.com/rails/rails/issues/35417
  gem 'rspec-rails', '~> 4.0.0.beta2'
end

group :development do
  gem 'factory_bot_rails', '~> 4.0'
  gem 'fasterer'
  gem 'haml_lint', require: false
  gem 'listen', '>= 3.0.5', '< 3.2'
  gem 'rails_best_practices'
  gem 'reek'
  gem 'rubocop'
  gem 'scss_lint', require: false
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
  gem 'web-console', '>= 3.3.0'
end

group :test do
  # Adds support for Capybara system testing and selenium driver
  gem 'capybara', '>= 2.15'
  gem 'rspec_junit_formatter'
  gem 'selenium-webdriver'
  # Easy installation and use of web drivers to run system tests with browsers
  gem 'webdrivers'
  gem 'webmock'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]

gem 'administrate', '0.12.0'
gem 'bootstrap', '~> 4.3', '>= 4.3.1'
gem 'devise', '~> 4.6', '>= 4.6.1'
gem 'devise-bootstrapped',  github: 'excid3/devise-bootstrapped',
                            branch: 'bootstrap4'
gem 'devise_masquerade', '~> 0.6.2'
gem 'font-awesome-sass', '~> 5.6', '>= 5.6.1'
gem 'friendly_id', '~> 5.2', '>= 5.2.5'
gem 'gibbon'
gem 'gmaps4rails'
gem 'gravatar_image_tag', github: 'mdeering/gravatar_image_tag'
gem 'httparty'
gem 'mini_magick', '~> 4.9', '>= 4.9.2'
gem 'name_of_person', '~> 1.1'
gem 'omniauth-facebook', '~> 5.0'
gem 'omniauth-github', '~> 1.3'
gem 'omniauth-twitter', '~> 1.4'
gem 'pundit', '~> 1.1.0'
gem 'sidekiq', '~> 5.2', '>= 5.2.5'
gem 'sitemap_generator', '~> 6.0', '>= 6.0.1'
gem 'underscore-rails'
gem 'whenever', require: false

然后我尝试:-

docker-compose build
docker-compose up

连同以下的每一种组合:-

  • 在我的 dockerfile 中使用 bundle update mimemagic
  • 使用 gem 'mimemagic', '~&gt; 0.3.7' 专门将 gem 添加到我的 Gemfile
  • 手动将我的 Gemfile.lock mimemagic 版本从 0.3.5 更改为 0.3.7
  • RUN apt-get install shared-mime-info 添加到我的 Dockefile 中

我只是得到以下之一:-

Could not find mimemagic-0.3.x in any of the sources
web_1  | Bundler::GemNotFound: You have requested:
web_1  |   mimemagic ~> 0.3.7
web_1  | 
web_1  | The bundle currently has mimemagic locked at 0.3.5.
web_1  | Try running `bundle update mimemagic`

我还尝试将导轨撞到 6.0.3.6 并再次运行 docker 构建,这给了我主动支持问题:-

web_1  | Bundler::VersionConflict: Bundler could not find compatible versions for gem "activesupport":
web_1  |   In snapshot (Gemfile.lock):
web_1  |     activesupport (= 6.0.3.5)
web_1  | 
web_1  |   In Gemfile:
web_1  |     rails (~> 6.0.3.6) was resolved to 6.0.3.6, which depends on
web_1  |       activesupport (= 6.0.3.6)
web_1  | 
web_1  |     dotenv-rails was resolved to 2.7.6, which depends on
web_1  |       railties (>= 3.2) was resolved to 6.0.3.5, which depends on
web_1  |         activesupport (= 6.0.3.5)
web_1  | 
web_1  | Running `bundle update` will rebuild your snapshot from scratch, using only
web_1  | the gems in your Gemfile, which may resolve the conflict.

我需要做什么才能安装这个 gem?

【问题讨论】:

  • 可能是那个版本的 rails 锁定了 mimemagic。检查您的 Gemfile.lock。使用最新版本。如果它是一个新项目,则没有理由使用旧版本,也没有发布候选版本。 gem 'rails', '~&gt; 6.1'。您应该在部署之前进行捆绑更新。
  • 这不是一个全新的项目——很新。不过,这是第一次在这台笔记本电脑上进行设置。我尝试将它撞到 rails 6.0.3.6,它给了我帖子中提到的 activesupport 错误。
  • @Schwern 在部署之前进行捆绑更新是什么意思?我不会在任何地方部署这个项目。
  • 您正在 Docker 上部署/安装它。 Gemfile.lock 的重点是锁定 gem 的版本以获得一致的安装。 bundle update 就在 bundle install 失败之前。它也很慢,你不需要在 Docker 中捆绑更新,你可以在任何地方进行。无论如何,您的 Gemfile 中的 else 是什么? dotenv-rails 不是 rails 依赖项。
  • @Schwern 其他一些东西 - 将它们添加到帖子中。尽管如此,Rails 的 activesupport 依赖仍然存在问题,无论 dot-env 是什么。

标签: ruby-on-rails ruby docker


【解决方案1】:
bundle update --conservative mimemagic 

也尝试使用较新的版本,而不是锁定它。 0.3.9 对我们有用,但现在有 0.3.10(没试过),

【讨论】:

  • 感谢它在 ruby​​ 2.6.6mimemagic 0.3.10 (was 0.3.5) 上为我工作
  • 在 ruby​​ 2.5.8 上与 mimemagic 0.3.10 相同的错误(原为 0.3.9)
  • 谢谢。它对我们有用。我们正在运行 Rails 5.2.3 和 Ruby 2.5.1。 mimagic 现在是 0.3.10(原为 0.3.4)
【解决方案2】:

使用以下方法解决:

bundle update mimemagic

我在安装包时收到错误 Your bundle is locked to mimemagic (0.3.5) from rubygems

这将 mimemagic 版本更新为 0.3.10 并为我在 Gemfile.lock 中添加了 nokigirirake 依赖项。

【讨论】:

    【解决方案3】:

    您可以按如下方式修改您的 Gemfile:

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

    更多详情here

    【讨论】:

    • 您应该编辑此答案以合并您的其他答案,因为该答案来自一个标记为与该答案重复的问题。
    【解决方案4】:

    对于我来说,这是来自 macOS 的解决方案: '您将需要 Freedesktop.org shared-mime-info 数据库的副本才能使用。如果您在 Linux 上,它可能可以通过您的包管理器获得,并且可能位于安装 gem 时要查找的位置。

    macOS 用户可以通过 Homebrew 使用 brew install shared-mime-info 安装数据库。' https://github.com/mimemagicrb/mimemagic

    【讨论】:

      【解决方案5】:

      其他解决方案可能会更新比您想要的更多的宝石。

      另一种解决方案是编辑您的Gemfile.lock

      找到上面写着的那一行 mimemagic (0.3.5)

      替换为 mimemagic (0.3.10)

      或您在此处找到的最高 0.3.x 版本:https://github.com/mimemagicrb/mimemagic/tags

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-03-08
        • 1970-01-01
        • 1970-01-01
        • 2014-06-18
        • 2018-04-08
        • 2012-04-19
        • 2015-03-04
        • 2014-07-11
        相关资源
        最近更新 更多