0

当 mina deploy 在迁移过程中发生错误时,未加载 pg gem。问题是 gem 已加载到我的 gem 文件中,但在 mina 的 bundle install 期间未安装 pg gem。

任何想法如何解决这个问题?

-----> Migrating database
   $ RAILS_ENV="production" bundle exec rake db:migrate
   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).

宝石文件

gem 'mail_form'
gem 'devise'
gem 'cancancan'

group :production do
     gem 'pg'
     gem 'therubyracer' 
   end

数据库.yml

production:  
    adapter: postgresql
    encoding: unicode
    database: tech
    username: admin
    password: PASSWORD
    host: localhost

mina 部署 --verbose

 -----> Loading rbenv
       $ export RBENV_ROOT="$HOME/.rbenv"
       $ export PATH="$HOME/.rbenv/bin:$PATH"
       $ eval "$(rbenv init -)"

-----> Creating a temporary build path
       $ touch "deploy.lock"
       $ mkdir -p "$build_path"
       $ cd "$build_path"

-----> Fetching new git commits
       $ (cd "/home/deployer/tech/scm" && git fetch "git@bitbucket.org:gns/tech.git" "master:m       
       $ (cd "/home/deployer/tech/scm" && git fetch "git@bitbucket.org:gns/tech.git" "master:master" --force)

-----> Using git branch 'master'
       $ git clone "/home/deployer/tech/scm" . --recursive --branch "master"
       Cloning into '.'...
       done.

-----> Using this git commit

       $ git --no-pager log --format='%aN (%h):%n> %s' -n 1
       yiannis (4ef997e):
       > Gemfile
       $ rm -rf .git


-----> Symlinking shared paths
       $ mkdir -p "./config"
       $ mkdir -p "."
       $ rm -rf "./config/database.yml"
       $ ln -s "/home/deployer/tech/shared/config/database.yml" "./config/database.yml"
       $ rm -rf "./log"
       $ ln -s "/home/deployer/tech/shared/log" "./log"
       $ rm -rf "./config/secrets.yml"
       $ ln -s "/home/deployer/tech/shared/config/secrets.yml" "./config/secrets.yml"

-----> Installing gem dependencies using Bundler
       $ mkdir -p "/home/deployer/tech/shared/bundle"
       $ mkdir -p "./vendor"
       $ ln -s "/home/deployer/tech/shared/bundle" "./vendor/bundle"
       $ bundle install --without development:test --path "./vendor/bundle" --deployment
       Fetching gem metadata from http://rubygems.org/........
       Using rake 10.4.2
       Using i18n 0.6.11
       Using json 1.8.1
       Using minitest 5.5.0
       Using thread_safe 0.3.4
       Using tzinfo 1.2.2
       Using activesupport 4.1.8
       Using builder 3.2.2
       Using erubis 2.7.0
       Using actionview 4.1.8
       Using rack 1.5.2
       Using rack-test 0.6.2
       Using actionpack 4.1.8
       Using mime-types 2.4.3
       Using mail 2.6.3
       Using actionmailer 4.1.8
       Using activemodel 4.1.8
       Using arel 5.0.1.20140414130214
       Using activerecord 4.1.8
       Using bundler 1.8.0.pre
       Using thor 0.19.1
       Using railties 4.1.8
       Using hike 1.2.3
       Using multi_json 1.10.1
       Using tilt 1.4.1
       Using sprockets 2.12.3
       Using sprockets-rails 2.2.2
       Using rails 4.1.8
       Using animate-rails 1.0.7
       Using aws-sdk-v1 1.59.1
       Using aws-sdk 1.59.1
       Using cancancan 1.9.2
       Using chronic 0.10.2
       Using climate_control 0.0.3
       Using cocaine 0.5.5
       Using coffee-script-source 1.8.0
       Using execjs 2.2.2
       Using coffee-script 2.3.0
       Using coffee-rails 4.0.1
       Using orm_adapter 0.5.0
       Using responders 1.1.2
       Using warden 1.2.3
       Using devise 3.4.1
       Using figaro 1.0.0
       Using font-awesome-rails 4.2.0.0
       Using foundation-datetimepicker-rails 0.1.3
       Using sass 3.2.19
       Using foundation-rails 5.4.5.0
       Using friendly_id 5.0.4
       Using google-webfonts-rails 0.0.4
       Using jbuilder 2.2.6
       Using jquery-rails 3.1.2
       Using kaminari 0.16.1
       Using libv8 3.16.14.7
       Using mail_form 1.5.0
       Using newrelic_rpm 3.9.8.273
       Using paperclip 4.2.1
       Using pg_search 0.7.8
       Using rdoc 4.2.0
       Using ref 1.0.5
       Using sass-rails 4.0.5
       Using sdoc 0.4.1
       Using therubyracer 0.12.1
       Using uglifier 2.6.0
       Using whenever 0.9.4
       Bundle complete! 25 Gemfile dependencies, 65 gems now installed.
       Gems in the groups development and test were not installed.
       Bundled gems are installed into ./vendor/bundle.

-----> Migrating database
       $ RAILS_ENV="production" bundle exec rake db:migrate
       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).
       /home/deployer/tech/tmp/build-142229948411279/vendor/bundle/ruby/2.1.0/gems/activerecord-4.1.8/lib/active_record/connection_adapters/connection_specification.rb:190:in `rescue in spec'
       /home/deployer/tech/tmp/build-142229948411279/vendor/bundle/ruby/2.1.0/gems/activerecord-4.1.8/lib/active_record/connection_adapters/connection_specification.rb:187:in `spec'
       /home/deployer/tech/tmp/build-142229948411279/vendor/bundle/ruby/2.1.0/gems/activerecord-4.1.8/lib/active_record/connection_handling.rb:50:in `establish_connection'
       /home/deployer/tech/tmp/build-142229948411279/vendor/bundle/ruby/2.1.0/gems/activerecord-4.1.8/lib/active_record/railtie.rb:129:in `block (2 levels) in <class:Railtie>'
       /home/deployer/tech/tmp/build-142229948411279/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.8/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval'
       /home/deployer/tech/tmp/build-142229948411279/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.8/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook'
       /home/deployer/tech/tmp/build-142229948411279/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.8/lib/active_support/lazy_load_hooks.rb:28:in `block in on_load'
       /home/deployer/tech/tmp/build-142229948411279/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.8/lib/active_support/lazy_load_hooks.rb:27:in `each'
       /home/deployer/tech/tmp/build-142229948411279/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.8/lib/active_support/lazy_load_hooks.rb:27:in `on_load'
       /home/deployer/tech/tmp/build-142229948411279/vendor/bundle/ruby/2.1.0/gems/activerecord-4.1.8/lib/active_record/railtie.rb:118:in `block in <class:Railtie>'
       /home/deployer/tech/tmp/build-142229948411279/vendor/bundle/ruby/2.1.0/gems/railties-4.1.8/lib/rails/initializable.rb:30:in `instance_exec'
       /home/deployer/tech/tmp/build-142229948411279/vendor/bundle/ruby/2.1.0/gems/railties-4.1.8/lib/rails/initializable.rb:30:in `run'
       /home/deployer/tech/tmp/build-142229948411279/vendor/bundle/ruby/2.1.0/gems/railties-4.1.8/lib/rails/initializable.rb:55:in `block in run_initializers'
       /home/deployer/tech/tmp/build-142229948411279/vendor/bundle/ruby/2.1.0/gems/railties-4.1.8/lib/rails/initializable.rb:54:in `run_initializers'
       /home/deployer/tech/tmp/build-142229948411279/vendor/bundle/ruby/2.1.0/gems/railties-4.1.8/lib/rails/application.rb:300:in `initialize!'
       /home/deployer/tech/tmp/build-142229948411279/config/environment.rb:5:in `<top (required)>'
       /home/deployer/tech/tmp/build-142229948411279/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:247:in `require'
       /home/deployer/tech/tmp/build-142229948411279/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:247:in `block in require'
       /home/deployer/tech/tmp/build-142229948411279/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:232:in `load_dependency'
       /home/deployer/tech/tmp/build-142229948411279/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:247:in `require'
       /home/deployer/tech/tmp/build-142229948411279/vendor/bundle/ruby/2.1.0/gems/railties-4.1.8/lib/rails/application.rb:276:in `require_environment!'
       /home/deployer/tech/tmp/build-142229948411279/vendor/bundle/ruby/2.1.0/gems/railties-4.1.8/lib/rails/application.rb:389:in `block in run_tasks_blocks'
       Gem::LoadError: pg is not part of the bundle. Add it to Gemfile.
       /home/deployer/tech/tmp/build-142229948411279/vendor/bundle/ruby/2.1.0/gems/activerecord-4.1.8/lib/active_record/connection_adapters/postgresql_adapter.rb:13:in `<top (required)>'
       /home/deployer/tech/tmp/build-142229948411279/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:247:in `require'
       /home/deployer/tech/tmp/build-142229948411279/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:247:in `block in require'
       /home/deployer/tech/tmp/build-142229948411279/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:232:in `load_dependency'
       /home/deployer/tech/tmp/build-142229948411279/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:247:in `require'
       /home/deployer/tech/tmp/build-142229948411279/vendor/bundle/ruby/2.1.0/gems/activerecord-4.1.8/lib/active_record/connection_adapters/connection_specification.rb:188:in `spec'
       /home/deployer/tech/tmp/build-142229948411279/vendor/bundle/ruby/2.1.0/gems/activerecord-4.1.8/lib/active_record/connection_handling.rb:50:in `establish_connection'
       /home/deployer/tech/tmp/build-142229948411279/vendor/bundle/ruby/2.1.0/gems/activerecord-4.1.8/lib/active_record/railtie.rb:129:in `block (2 levels) in <class:Railtie>'
       /home/deployer/tech/tmp/build-142229948411279/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.8/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval'
       /home/deployer/tech/tmp/build-142229948411279/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.8/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook'
       /home/deployer/tech/tmp/build-142229948411279/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.8/lib/active_support/lazy_load_hooks.rb:28:in `block in on_load'
       /home/deployer/tech/tmp/build-142229948411279/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.8/lib/active_support/lazy_load_hooks.rb:27:in `each'
       /home/deployer/tech/tmp/build-142229948411279/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.8/lib/active_support/lazy_load_hooks.rb:27:in `on_load'
       /home/deployer/tech/tmp/build-142229948411279/vendor/bundle/ruby/2.1.0/gems/activerecord-4.1.8/lib/active_record/railtie.rb:118:in `block in <class:Railtie>'
       /home/deployer/tech/tmp/build-142229948411279/vendor/bundle/ruby/2.1.0/gems/railties-4.1.8/lib/rails/initializable.rb:30:in `instance_exec'
       /home/deployer/tech/tmp/build-142229948411279/vendor/bundle/ruby/2.1.0/gems/railties-4.1.8/lib/rails/initializable.rb:30:in `run'
       /home/deployer/tech/tmp/build-142229948411279/vendor/bundle/ruby/2.1.0/gems/railties-4.1.8/lib/rails/initializable.rb:55:in `block in run_initializers'
       /home/deployer/tech/tmp/build-142229948411279/vendor/bundle/ruby/2.1.0/gems/railties-4.1.8/lib/rails/initializable.rb:54:in `run_initializers'
       /home/deployer/tech/tmp/build-142229948411279/vendor/bundle/ruby/2.1.0/gems/railties-4.1.8/lib/rails/application.rb:300:in `initialize!'
       /home/deployer/tech/tmp/build-142229948411279/config/environment.rb:5:in `<top (required)>'
       /home/deployer/tech/tmp/build-142229948411279/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:247:in `require'
       /home/deployer/tech/tmp/build-142229948411279/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:247:in `block in require'
       /home/deployer/tech/tmp/build-142229948411279/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:232:in `load_dependency'
       /home/deployer/tech/tmp/build-142229948411279/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.8/lib/active_support/dependencies.rb:247:in `require'
       /home/deployer/tech/tmp/build-142229948411279/vendor/bundle/ruby/2.1.0/gems/railties-4.1.8/lib/rails/application.rb:276:in `require_environment!'
       /home/deployer/tech/tmp/build-142229948411279/vendor/bundle/ruby/2.1.0/gems/railties-4.1.8/lib/rails/application.rb:389:in `block in run_tasks_blocks'
       Tasks: TOP => db:migrate => environment
       (See full trace by running task with --trace)
 !     ERROR: Deploy failed.

-----> Cleaning up build
       $ rm -rf "$build_path"
       Unlinking current
       $ rm -f "deploy.lock"
       OK

 !     Command failed.
       Failed with status 19
4

1 回答 1

0

我确定 只为和命令set :rails_env, 'production'设置环境,所以试试bundle_prefixrakerails

在最坏的情况下移动gem 'pg'到 Gemfile 的公共部分。

于 2015-01-25T08:32:17.783 回答