我正在尝试在 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 真的很陌生,事实上我正在尝试开始学习它,所以我不知道如何解决这个问题。
最佳答案
问题在于 devise 和 simple_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]
然后运行捆绑安装
如果需要,还可以考虑更新 haml gem:
gem 'haml', '~> 5.0.4'
而不是 gem 'haml', '~> 4.0.5'
然后运行捆绑更新
关于ruby-on-rails - Bundler 安装 - 找不到 gem "actionpack"的兼容版本 - Rails 5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52959661/