添加gem“ font-awesome-rails”后的捆绑安装问题

时间:2018-11-06 19:23:48

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

我正在使用Udemy的教程来创建Web应用程序,并且正在使用cloud9 IDE。一切工作正常,直到添加了真棒字体。在添加超棒的gem之后尝试捆绑安装时,出现以下错误:

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

    web-console (>= 3.3.0) was resolved to 3.3.0, which depends on
      activemodel (>= 4.2)

Bundler could not find compatible versions for gem "activesupport":
  In Gemfile:
    jbuilder (~> 2.5) was resolved to 2.8.0, which depends on
      activesupport (>= 4.2.0)

    rails (~> 5.2.0) was resolved to 5.2.1.rc1, which depends on
      activesupport (= 5.2.1.rc1)

    spring was resolved to 2.0.2, which depends on
      activesupport (>= 4.2)

Bundler could not find compatible versions for gem "railties":
  In Gemfile:
    coffee-rails (~> 4.2) was resolved to 4.2.2, which depends on
      railties (>= 4.0.0)

    font-awesome-rails (= 4.2.0) was resolved to 4.2.0.0, which depends on
      railties (< 5.0, >= 3.2)

    jquery-rails was resolved to 4.3.3, which depends on
      railties (>= 4.2.0)

    rails (~> 5.2.0) was resolved to 5.2.1.rc1, which depends on
      railties (= 5.2.1.rc1)

    sass-rails (~> 5.0) was resolved to 5.0.7, which depends on
      railties (< 6, >= 4.0.0)

    web-console (>= 3.3.0) was resolved to 3.3.0, which depends on
      railties (>= 4.2)

这是我当前的gem文件:

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

ruby '2.4.1'

gem 'rails', '~> 5.2.0'

gem 'sqlite3', group: [:development, :test]


gem 'bootstrap-sass', '~> 3.3.7'

gem "font-awesome-rails", '4.2.0'


gem 'jquery-rails'

group :production do
  gem 'pg'
  gem 'rails_12factor'

end


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 '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]

因此,在搜索了类似的问题之后,我尝试删除我的gemlock文件并运行捆绑软件更新,但没有成功。尝试运行服务器只会给我一个错误,需要首先安装'font-awesome-rails'软件包。

还为格式表示歉意,这是我的第一个问题。任何帮助表示赞赏。

1 个答案:

答案 0 :(得分:0)

问题在于以下约束:

gem "font-awesome-rails", '4.2.0'

如以下部分所述:

font-awesome-rails (= 4.2.0) was resolved to 4.2.0.0, which depends on
  railties (< 5.0, >= 3.2)

font-awesome-rails的4.2版本要求Rails <5.0,但是您正在使用Rails 5.2.0,因此捆绑程序不知道要做什么(给定gem不能有多个版本)。

解决方案是为我们提供无版本的gem声明:

gem "font-awesome-rails"

不用担心该gem的版本,捆绑程序足够聪明,可以为您提供最新的兼容版本!

注意:您也可以使用the pessimistic operator,如:

gem "font-awesome-rails", '~> 4.2'