我已尽一切努力将我的数据库更改为 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.
gem 文件
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
数据库.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
的路径。你会找到答案 here .
关于ruby-on-rails - 将数据库从 SQLite 更改为 Postgresql : "gem install pg" error?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34022930/