Bundler 安装 - 找不到 gem "actionpack" - Rails 5 的兼容版本

Bundler install - could not find compatible versions for gem "actionpack" - Rails 5

我正在尝试在 rails 上设置 ruby 以开始研究它,但是当我 运行 捆绑安装时我一直收到此错误。

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 的新手,事实上我正在尝试开始学习它,所以我不知道如何解决这个问题。

问题是 devisesimple_form gems 已经过时并且与当前不兼容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', '~> 5.0.4' 而不是 gem 'haml', '~> 4.0.5'

然后 运行 bundle update