【问题标题】:Bundler install - could not find compatible versions for gem "actionpack" - Rails 5Bundler install - 找不到 gem“actionpack”的兼容版本 - Rails 5
【发布时间】:2019-03-28 07:37:59
【问题描述】:

我正在尝试在 Rails 上设置 ruby​​ 以开始研究它,但在运行 bundle install 时我不断收到此错误。

Bundler could not find compatible versions for gem "actionpack":
  In Gemfile:
    rails (~> 5.2.0) was resolved to 5.2.0, which depends on
      actionpack (= 5.2.0)

    simple_form (~> 3.0.2) was resolved to 3.0.4, which depends on
      actionpack (~> 4.0)

Bundler could not find compatible versions for gem "rails":
  In Gemfile:
    rails (~> 5.2.0)

Could not find gem 'rails (~> 5.2.0)' in any of the sources.

我的 Gemfile 是这样的:

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

ruby '2.5.1'

gem 'rails', '~> 5.2.0'
gem 'sqlite3'
gem 'puma', '~> 3.11'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'

gem 'coffee-rails', '~> 4.2'
gem 'turbolinks', '~> 5'
gem 'jbuilder', '~> 2.5'
gem 'devise', '~> 3.4.1'
gem 'simple_form', '~> 3.0.2'
gem 'haml', '~> 4.0.5'

gem 'bootsnap', '>= 1.1.0', require: false

group :development, :test do
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end

group :development do
  gem 'web-console', '>= 3.3.0'
  gem 'listen', '>= 3.0.5', '< 3.2'
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
end

group :test do
  gem 'capybara', '>= 2.15', '< 4.0'
  gem 'selenium-webdriver'
  gem 'chromedriver-helper'
end
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

有人可以帮帮我吗? 我对rails真的很陌生,实际上我正在尝试开始学习它,所以我不知道如何解决这个问题。

【问题讨论】:

  • 删除文件gemfile.lock,然后再次执行bundle install。如果失败,请再次杀死 gemfile.lock 并以不同的方式对 gem 进行版本控制:gem 'rails', '= 5.2.0' gem 'simple_form'(此 gem 没有版本)
  • 嗨@Maxence,感谢您的回复。不幸的是,它没有用。我已经尝试删除 gemfile.lock 并为 gems 设置这些版本不起作用。还有什么想法吗?我仍然收到此操作包错误。
  • 尝试杀死git_source 行。并根据我之前的评论进行版本然后再次捆绑安装。
  • 仍然遇到同样的错误,现在还有更多,@Maxence。开始学习 Rails 让我很兴奋,但这太让人失望了。
  • 能否请大家停止建议“删除所有内容并重新开始”?阅读错误信息。它指出 rails 和 simple_form 版本之间不兼容。如果您认为错误消息不清楚,也许您可​​以向 bundler 团队提出这个问题,并提出更好的格式。就个人而言,我认为这是完全可以理解的。

标签: ruby-on-rails ruby rubygems ruby-on-rails-5


【解决方案1】:

根据第一个答案,请告诉我应该在哪里修改 Gemfile?谢谢!

source 'https://rubygems.org'
source 'https://rails-assets.org'

git_source(:github) do |repo_name|
  repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
  "https://github.com/#{repo_name}.git"
end

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.1.4'

# ActiveModel::Serializer implementation and Rails hooks
# gem 'active_model_serializers', require: true

# Use postgres as the database for Active Record
gem 'pg', '~> 0.18'
# Use Puma as the app server
gem 'puma', '~> 3.7'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
gem 'unicorn'

# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# 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', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

gem 'bugsnag'

# Rack Middleware for handling Cross-Origin Resource Sharing (CORS), which makes cross-origin AJAX possible.
gem 'rack-cors', require: 'rack/cors'

# Authentications & authorizations
gem 'devise', '~> 4.5', github: 'heartcombo/devise', branch: 'main'
gem 'devise-i18n'
gem 'omniauth-facebook'
gem 'omniauth-github'
gem 'omniauth-google-oauth2'
gem 'devise_token_auth', '0.1.43'

# The solution to keep your Rails ActiveRecord migrations up to date
gem 'migration_data'

# Easiest way to add multi-environment yaml settings to Rails, Sinatra, Pandrino and other ruby projects.
gem 'config'

# Classier solution for file uploads for Rails, Sinatra and other Ruby web frameworks
gem 'carrierwave'

# Fog is used to support Amazon S3.
# If you cannot install json gem, try `brew install coreutils`
gem 'fog'

# FriendlyId is the “Swiss Army bulldozer” of slugging and permalink plugins for ActiveRecord. It allows you to create pretty URL’s and work with human-friendly strings as if they were numeric ids for ActiveRecord models
gem 'friendly_id', '~> 5.2.0'

# A library for creating slugs. Babosa is an extraction and improvement of the string code from FriendlyId, intended to help developers create similar libraries or plugins.
gem 'babosa'

# translate chinese hanzi to pinyin
gem 'chinese_pinyin'

# Ruby library for the Stripe API. https://stripe.com
gem 'stripe'

# Ruby on Rails unobtrusive scripting adapter for jQuery
gem 'jquery-rails'

# Simple, efficient background processing for Ruby.
gem 'sidekiq'
gem 'sidekiq-cron'
gem 'sidekiq-unique-jobs', '5.0.10'

# Intelligent search made easy with Rails and Elasticsearch
gem 'searchkick'
gem 'faraday_middleware-aws-sigv4'


# All sorts of useful information about every country packaged as convenient little country objects. It includes data from ISO 3166 (countries and states/subdivisions ), ISO 4217 (currency), and E.164 (phone numbers).
gem 'countries'

# Rails I18n de-facto standard library for ActiveRecord model/data translation.
gem 'globalize', git: 'https://github.com/globalize/globalize'
gem 'activemodel-serializers-xml'

# A Ruby gem to load environment variables from `.env`.
gem 'dotenv-rails'

# Pagination library for Rails, Sinatra, Merb, DataMapper
# gem 'will_paginate', '~> 3.1.0'

gem 'blog', path: './engines/blog'
# gem 'events', path: './engines/events'
# gem 'healthcare', path: './engines/healthcare'

# Spreeeed custom backend engine
gem 'spreeeed_engine', :git => 'https://github.com/MidnightBlue/spreeeed_engine.git'

# A service for server-side rendering your JavaScript views
gem 'hypernova'

# Brings Rails named routes to javascript http://railsware.github.io/js-routes/
gem 'js-routes'

# Simple HTTP and REST client for Ruby, inspired by microframework syntax for specifying actions.
gem 'rest-client'

# A Ruby Library for dealing with money and currency conversion.
gem 'money'

# A gem that calculates the exchange rate using published rates from European Central Bank. Compatible with the money gem.
gem 'eu_central_bank', github: 'RubyMoney/eu_central_bank', branch: 'main'

# Complete Ruby geocoding solution.
gem 'geocoder'

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]

  # Adds support for Capybara system testing and selenium driver
  gem 'capybara', '~> 2.13'
  gem 'selenium-webdriver'

  # Preview mail in the browser instead of sending.
  gem 'letter_opener'

  #stud_request
  gem 'webmock'

  #BDD test with rspec
  gem 'rspec-rails'

  # RDoc produces HTML and online documentation for Ruby projects. RDoc includes the rdoc and ri tools for generating and displaying online documentation.
  gem 'rdoc'

  # Minitest integration for Rails
  gem 'minitest-rails'

  # A library for setting up Ruby objects as test data.
  gem "factory_bot_rails", "~> 4.0"
end

group :development do
  # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
  gem 'web-console', '>= 3.3.0'
  gem 'listen', '>= 3.0.5', '< 3.2'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'

  # Pretty print your Ruby objects with style -- in full color and with proper indentation
  gem 'awesome_print', require: true

  # Annotate Rails classes with schema and routes info
  gem 'annotate'

  gem 'mysql2'

end

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

# Nokogiri (鋸) is an HTML, XML, SAX, and Reader parser. Among Nokogiri's many features is the ability to search documents via XPath or CSS3 selectors.
gem 'nokogiri'

#report 500
gem 'sentry-raven'

gem 'rails_autolink'

【讨论】:

    【解决方案2】:

    问题在于 devisesimple_form gem 已经过时并且与当前版本的 rails 不兼容。

    您可以尝试像这样安装较新的版本:

    source 'https://rubygems.org'
    git_source(:github) { |repo| "https://github.com/#{repo}.git" }
    
    ruby '2.5.1'
    
    gem 'rails', '~> 5.2.0'
    gem 'sqlite3'
    gem 'puma', '~> 3.11'
    gem 'sass-rails', '~> 5.0'
    gem 'uglifier', '>= 1.3.0'
    
    gem 'coffee-rails', '~> 4.2'
    gem 'turbolinks', '~> 5'
    gem 'jbuilder', '~> 2.5'
    gem 'devise', '~> 4.5.0'
    gem 'simple_form', '~> 4.0.1'
    gem 'haml', '~> 4.0.5'
    
    gem 'bootsnap', '>= 1.1.0', require: false
    
    group :development, :test do
      gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
    end
    
    group :development do
      gem 'web-console', '>= 3.3.0'
      gem 'listen', '>= 3.0.5', '< 3.2'
      gem 'spring'
      gem 'spring-watcher-listen', '~> 2.0.0'
    end
    
    group :test do
      gem 'capybara', '>= 2.15', '< 4.0'
      gem 'selenium-webdriver'
      gem 'chromedriver-helper'
    end
    gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
    

    然后运行bundle install

    如果需要,还可以考虑更新 haml gem:

    gem 'haml', '~&gt; 5.0.4' 而不是gem 'haml', '~&gt; 4.0.5'

    然后运行bundle update

    【讨论】:

    • 很高兴为您提供帮助:)
    • 感谢 MibraDev,您为我节省了时间和精力。
    • 不工作,我的 gemfile 部分是:gem 'devise','~> 4.5',github:'heartcombo/devise',分支:'main' gem 'devise-i18n' gem 'omniauth -facebook' gem 'omniauth-github' gem 'omniauth-google-oauth2' gem 'devise_token_auth', '0.1.43'
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-08-14
    • 2011-10-31
    • 2013-06-30
    • 2023-03-14
    相关资源
    最近更新 更多