繁体   English   中英

将数据库从SQLite更改为Postgresql:“gem install pg”错误?

[英]Change database from SQLite to Postgresql: “gem install pg” error?

我已经做了一切将我的数据库更改为Postgresql。

1)我尝试从自制程序卸载并安装2)我已经尝试从www.postgresql.org安装postgresql

但是他们两个都没有工作..当我尝试安装“gem pg”时我遇到了同样的错误

 $bundle install
 .
 .
 Installing pg 0.17.1 with native extensions

 Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

 current directory: /private/var/folders/jd/dn7zyf593n97j1rdjbbh_hl00000gn/T/bundler20151201-657-1v67eg6pg-0.17.1/gems/pg-0.17.1/ext
 /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -r ./siteconf20151201-657-kkjx98.rb extconf.rb --with-pg config=/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config
  Using config values from /Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config
  sh: /Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config: No such file or directory
  sh: /Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config: No such file or directory
  checking for libpq-fe.h... no
   Can't find the 'libpq-fe.h header
  *** extconf.rb failed ***
  Could not create Makefile due to some reason, probably lack of necessary
  libraries and/or headers.  Check the mkmf.log file for more details.  You may
  need configuration options.

  Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
--with-pg
--without-pg
--with-pg-config
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/

  To see why this extension failed to compile, please check the mkmf.log which can be found here:

 /var/folders/jd/dn7zyf593n97j1rdjbbh_hl00000gn/T/bundler20151201-657-1v67eg6pg-0.17.1/extensions/universal-darwin-15/2.0.0/pg-0.17.1/mkmf.log

  extconf failed, exit code 1

  Gem files will remain installed in /var/folders/jd/dn7zyf593n97j1rdjbbh_hl00000gn/T/bundler20151201-657-1v67eg6pg-0.17.1/gems/pg-0.17.1 for inspection.
 Results logged to /var/folders/jd/dn7zyf593n97j1rdjbbh_hl00000gn/T/bundler20151201-657-1v67eg6pg-0.17.1/extensions/universal-darwin-15/2.0.0/pg-0.17.1/gem_make.out


 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.

的Gemfile

 gem 'rails', '4.2.4'
 gem 'sdoc', '~> 0.4.0', group: :doc

 gem 'bootstrap-sass', '~> 3.2.0'
 gem 'autoprefixer-rails'
 gem 'pg', '0.17.1' 

 group :development, :test do

 gem 'sqlite3'
 gem 'byebug'
 gem 'web-console', '~> 2.0'
 gem 'spring'

 end

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

database.yml的

default: &default
adapter: sqlite3
pool: 5
timeout: 5000

development:
adapter: postgresql
encoding: unicode
database: blog_development
pool: 5
username: ****
password: <!--- this place is **EMPTY** -->

test:
adapter: postgresql
encoding: unicode
database: blog_development
pool: 5
username: ****
password: <!--- this place is **EMPTY** -->

production:
 <<: *default
 database: db/production.sqlite3

您必须提供pg_config的路径。 你会在这里找到答案。

我猜pg gem找不到postgres安装。 我想你正在使用Mac,如果是这样的话,试试Postgress.app http://postgresapp.com/ ,它非常直接。

这看起来像是重复的

在尝试安装pg gem时找不到'libpq-fe.h标头

哪个,顺便说一句,是谷歌搜索的最佳结果“pg gem找不到libpq-fe.h标题”

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM