Ruby on rails Bundle安装不在Gemfile中安装gem
我正在键入以下命令:Ruby on rails Bundle安装不在Gemfile中安装gem,ruby-on-rails,bundle,gemfile,Ruby On Rails,Bundle,Gemfile,我正在键入以下命令: rake -RAILS_ENV=production db:schema:load 在生产服务器上我的rails应用程序的主目录中,我收到以下错误消息: rake aborted! Please install the postgresql adapter: `gem install activerecord-postgresql-adapter` (pg is not part of the bundle. Add it to Gemfile.) 这很奇怪,因为我知道
rake -RAILS_ENV=production db:schema:load
在生产服务器上我的rails应用程序的主目录中,我收到以下错误消息:
rake aborted!
Please install the postgresql adapter: `gem install activerecord-postgresql-adapter` (pg is not part of the bundle. Add it to Gemfile.)
这很奇怪,因为我知道pg在我的GEM文件中:
source 'https://rubygems.org'
gem 'rails', '3.2.8'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
group :development, :production do
gem 'pg'
gem 'devise'
gem 'haml-rails'
gem 'paperclip'
gem 'will_paginate'
end
group :development do
gem 'capistrano'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
当我从该目录运行bundle install
时,我得到以下输出(pg不在其上):
和my Gemfile.lock(如果相关)(pg仅作为依赖项列出):
我正在使用
-轨道3.2.8
-ruby 1.9.3
-rvm 1.16.5
有人能解释为什么bundle install没有安装我的Gemfile中列出的所有Gem吗?您必须使用bundler来执行rake:
bundle exec rake db:schema:load RAILS_ENV=production
对于database.yml
应该是
development:
adapter: postgresql
encoding: utf8
database: xxx
host: localhost
username: username
password: pw
postgresql的适配器是postgresql
对于gem文件,确保pg在那里
如果在开发和生产过程中都存在块,则不需要它。通过一些调查工作,我发现以下因素导致了我的问题: 1) 我是在一台Windows机器上开发的,它安装了特定于Windows的gem pg版本:(0.14.0-x86-mingw32) 2) 然后,这被添加到我的Gemfile.lock中,并因此添加到我的repo中,capistrano随后使用该repo在Debian box上安装我的应用程序;pg仅列为依赖项 3) capistrano正在使用“-deployment”标志运行bundler,这要求Gemfile.lock是最新和准确的 我是如何解决问题的,在deploy.rb中使用以下变量定义从capistrano中删除了“-deployment”标志:
set :bundle_flags, "--quiet"
require 'bundler/capistrano'
并再次运行cap deploy:update
仍在努力让Gemfile.lock反映pg应该安装在生产环境中,而pg应该安装在开发机器上,这样我就可以将--deployment选项重新包含到部署任务中。您需要单独安装postgresql。。。你的操作系统是什么?请看这里:您的
.bundle/config
文件的内容是什么?谢谢,但我已经安装了postgresql哪个psql
提供了/usr/bin/psql
和psql--version
提供了psql(postgresql)9.1.6
。为了让它在rails上运行(在Debian安装上),我需要做些什么吗?.bundle/config的内容已经添加到了上面。奇怪的是,你说的是Debian
install,但是你的Gemfile.lock显示了一个windows构建平台(x86-mingw32
)。谢谢,但这会产生同样的错误消息。您能解释一下使用bundle命令和不使用bundle命令运行rake任务的区别吗?我从来都不清楚这一点。只是它使用包中定义的gemset运行rake任务吗?它确保加载的gems是gemfile中声明的gems。您可以发布bundle show pg
的输出吗?`在当前bundle中找不到gem“pg”。`将gem“pg”
放在块外。在所有项目中搜索对mingw
的引用。删除.bundle
目录,让系统托管您的gems。对不起,您说让系统托管您的gems是什么意思?database.yml已经看起来像这样了,而且Gemfile肯定已经包含“pg”。
bundle exec rake db:schema:load RAILS_ENV=production
development:
adapter: postgresql
encoding: utf8
database: xxx
host: localhost
username: username
password: pw
set :bundle_flags, "--quiet"
require 'bundler/capistrano'