特拉维斯CI找不到'pg'宝石

时间:2014-07-22 17:06:56

标签: ruby-on-rails rubygems bundler travis-ci

我正在使用Travis CI来测试我的Rails项目。 在构建我的提交时,它会在bundle exec rake上停止。

日志的一部分:

$ gem --version
2.2.2
$ bundle --version
Bundler version 1.6.2
$ bundle install --jobs=3 --retry=3 --deployment
Fetching gem metadata from https://rubygems.org/..........
Fetching additional metadata from https://rubygems.org/..
Installing i18n 0.6.11
Installing rake 10.3.2
Installing minitest 5.4.0
Installing thread_safe 0.3.4
Installing builder 3.2.2
Installing json 1.8.1
Installing erubis 2.7.0
Installing mime-types 1.25.1
Installing rack 1.5.2
Installing polyglot 0.3.5
Installing arel 5.0.1.20140414130214
Installing execjs 2.2.1
Installing coffee-script-source 1.7.1
Installing thor 0.19.1
Installing hike 1.2.3
Using bundler 1.6.2
Installing multi_json 1.10.1
Installing tilt 1.4.1
Installing rails_serve_static_assets 0.0.2
Installing rails_stdout_logging 0.0.3
Installing tzinfo 1.2.1
Installing sass 3.2.19
Installing rack-test 0.6.2
Installing rdoc 4.1.1
Installing treetop 1.4.15
Installing coffee-script 2.3.0
Installing uglifier 2.5.3
Installing sprockets 2.11.0
Installing rails_12factor 0.0.2
Installing sdoc 0.4.0
Installing activesupport 4.1.4
Installing mail 2.5.4
Installing actionview 4.1.4
Installing jbuilder 2.1.3
Installing activemodel 4.1.4
Installing actionpack 4.1.4
Installing activerecord 4.1.4
Installing railties 4.1.4
Installing sprockets-rails 2.1.3
Installing actionmailer 4.1.4
Installing coffee-rails 4.0.1
Installing jquery-rails 3.1.1
Installing sass-rails 4.0.3
Installing turbolinks 2.2.2
Installing rails 4.1.4
Your bundle is complete!
It was installed into ./vendor/bundle
Post-install message from rdoc:
Depending on your version of ruby, you may need to install ruby rdoc/ri data:
<= 1.8.6 : unsupported
 = 1.8.7 : gem install rdoc-data; rdoc-data --install
 = 1.9.1 : gem install rdoc-data; rdoc-data --install
>= 1.9.2 : nothing to do! Yay!
$ psql -c 'create database travis_ci_test;' -U postgres
CREATE DATABASE
$ cp config/database.yml.travis config/database.yml
$ bundle exec rake
rake aborted!
Gem::LoadError: Specified 'postgresql' for database adapter, but the gem is not loaded. Add `gem 'pg'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).

(如您所见,没有安装pg gem。)

我的.travis.yml:

language: ruby
rvm:
  - "2.0.0"
addons:
  postgresql: "9.3"
before_script:
  - psql -c 'create database travis_ci_test;' -U postgres
  - cp config/database.yml.travis config/database.yml

我的Gemfile:

source 'https://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.4'
# Use postgresql as the database for Active Record
gem 'pg'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer',  platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0',          group: :doc

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

gem 'rails_12factor', group: :production
ruby "2.0.0"

所以'pg'gem是在Gemfile中,它可以在我的电脑上运行,但是Travis没有安装它。

2 个答案:

答案 0 :(得分:0)

Gemfile.lock文件中的'pg'gem?如果没有,您可能需要删除此文件并通过再次运行bundle install重新生成它。

答案 1 :(得分:0)

从存储库中删除Gemfile.lock,现在构建和测试正在按预期工作。

我想这是因为在Windows上创建了锁文件,并且它包含一些特定于平台的内容(如gems的mingw32后缀)