Michael Hartl的gem文件包安装问题

时间:2015-09-23 19:19:45

标签: ruby-on-rails bundle gemfile

我正在尝试使用bundle install:

在Michael Hartl的教程中安装这个gem文件
source 'https://rubygems.org'

gem 'rails',                   '4.2.2'
gem 'bcrypt',                  '3.1.7'
gem 'faker',                   '1.4.2'
gem 'carrierwave',             '0.10.0'
gem 'mini_magick',             '3.8.0'
gem 'fog',                     '1.26.0'
gem 'will_paginate',           '3.0.7'
gem 'bootstrap-will_paginate', '0.0.10'
gem 'bootstrap-sass',          '3.2.0.0'
gem 'sass-rails',              '5.0.2'
gem 'uglifier',                '2.5.3'
gem 'coffee-rails',            '4.1.0'
gem 'jquery-rails',            '4.0.3'
gem 'turbolinks',              '2.3.0'
gem 'jbuilder',                '2.2.3'
gem 'sdoc',                    '0.4.0', group: :doc

group :development, :test do
  gem 'sqlite3',     '1.3.9'
  gem 'byebug',      '3.4.0'
  gem 'web-console', '2.0.0.beta3'
  gem 'spring',      '1.1.3'
end

group :test do
  gem 'minitest-reporters', '1.0.5'
  gem 'mini_backtrace',     '0.1.3'
  gem 'guard-minitest',     '2.3.1'
end

group :production do
  gem 'pg',             '0.17.1'
  gem 'rails_12factor', '0.0.2'
  gem 'puma',           '2.11.1'
end

我在终端上运行bundle install。我有这个错误:

Bundler could not find compatible versions for gem "actionpack":
In snapshot (Gemfile.lock):
actionpack (= 4.2.4)

In Gemfile:
railties (>= 0) ruby depends on
  actionpack (= 4.2.4) ruby

web-console (>= 0) ruby depends on
  sprockets-rails (< 4.0, >= 2.0) ruby depends on
    actionpack (>= 3.0) ruby

rails (= 4.2.2) ruby depends on
  actionpack (= 4.2.2) ruby

actionpack (>= 0) ruby

Running `bundle update` will rebuild your snapshot from scratch, using only
the gems in your Gemfile, which may resolve the conflict.

对于这里真正发生的事情有任何线索吗?我尝试了捆绑更新,它提示我:An error occurred while installing pg (0.17.1), and Bundler cannot continue. Make sure that gem install pg -v'0.17.1'succeeds before bundling.

然后,如果我安装了pg,它仍然不会这样做......

3 个答案:

答案 0 :(得分:1)

该教程中的生产块面向Heroku,您需要执行以下操作:

bundle install --without production

因为您当地的宝石集并不需要那些宝石。

答案 1 :(得分:0)

当您学习Rails时,您可能不打算将Michael Hartl的教程应用程序推向生产阶段。只需删除此块:

group :production do
  gem 'pg',             '0.17.1'
  gem 'rails_12factor', '0.0.2'
  gem 'puma',           '2.11.1'
end

通过这种方式&#39;&#39;不需要宝石。仅当您想使用postgresql服务器在生产中运行应用程序时才可以。

然后运行bundle update,它应该可以正常工作。

答案 2 :(得分:0)

在Linux上,安装这两个

sudo apt-get install postgresql
sudo apt-get install pgadmin3
bundle install

那对我有用