postgresql 为什么 bundle install 不允许 pg gem 完全安装?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7228798/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Why isn't bundle install allowing for the pg gem to fully install?
提问by Tony
I've installed the pg gem as shown, but...
如图所示,我已经安装了 pg gem,但是...
Building native extensions. This could take a while...
Successfully installed pg-0.11.0
ERROR: Could not find a valid gem '—' (>= 0) in any repository
ERROR: Could not find a valid gem '–with-pg-config=/usr/local/pg/bin/pg_config' (>= 0) in any repository
1 gem installed
Installing ri documentation for pg-0.11.0...
Installing RDoc documentation for pg-0.11.0...
Something strange happens when I bundle install and it won't completely install the pg gem:
当我 bundle install 并且它不会完全安装 pg gem 时,会发生一些奇怪的事情:
Fetching source index for http://rubygems.org/
Using rake (0.9.2)
Using abstract (1.0.0)
Using activesupport (3.0.10)
Using builder (2.1.2)
Using i18n (0.5.0)
Using activemodel (3.0.10)
Using erubis (2.6.6)
Using rack (1.2.3)
Using rack-mount (0.6.14)
Using rack-test (0.5.7)
Using tzinfo (0.3.29)
Using actionpack (3.0.10)
Using mime-types (1.16)
Using polyglot (0.3.2)
Using treetop (1.4.10)
Using mail (2.2.19)
Using actionmailer (3.0.10)
Using arel (2.0.10)
Using activerecord (3.0.10)
Using activeresource (3.0.10)
Using annotate (2.4.0)
Using bundler (1.0.18)
Using diff-lcs (1.1.2)
Using factory_girl (1.3.3)
Using rdoc (3.9.3)
Using thor (0.14.6)
Using railties (3.0.10)
Using rails (3.0.10)
Using factory_girl_rails (1.0)
Using faker (0.3.1)
Using gravatar_image_tag (1.0.0.pre2)
Using nokogiri (1.5.0)
Installing pg (0.11.0) with native extensions /Users/******/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:552:in `rescue in block in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)
Then I get the lines that tell me I may lack necessary libraries or headers:
然后我得到的行告诉我我可能缺少必要的库或头文件:
*** 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=/Users/TonyNg/.rvm/rubies/ruby-1.9.2-p180/bin/ruby
--with-pg
--without-pg
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/lib
--with-pg-config
extconf.rb:24:in ``': No such file or directory - /users/****/
Here is my gem file:
这是我的宝石文件:
source 'http://rubygems.org'
gem 'rails', '3.0.10'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'pg'
gem 'gravatar_image_tag', '1.0.0.pre2'
gem 'will_paginate', '3.0.pre2'
group :development do
gem 'rspec-rails', '2.6.1'
gem 'annotate', '2.4.0'
gem 'faker', '0.3.1'
end
group :test do
gem 'rspec-rails', '2.6.1'
gem 'webrat', '0.7.1'
gem 'spork', '0.9.0.rc8'
gem 'factory_girl_rails', '1.0'
end
# Use unicorn as the web server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+)
# gem 'ruby-debug'
# gem 'ruby-debug19', :require => 'ruby-debug'
# Bundle the extra gems:
# gem 'bj'
# gem 'nokogiri'
# gem 'sqlite3-ruby', :require => 'sqlite3'
# gem 'aws-s3', :require => 'aws/s3'
# Bundle gems for the local environment. Make sure to
# put test-only gems in this group so their generators
# and rake tasks are available in development mode:
# group :development, :test do
# gem 'webrat'
# end
How do I solve this issue? Thanks in advance.
我该如何解决这个问题?提前致谢。
EDITAnswer:The trick was to install the pg gem under the correctpathway to pg_config whereas before it wasn't fully installed. I ran 'gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config ' for the path I had put down under my last comment. I just had to locate my pg_config file and run gem install under that.
编辑答案:诀窍是在pg_config的正确路径下安装 pg gem,而在它没有完全安装之前。我运行'gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config '作为我在上一条评论下放置的路径。我只需要找到我的 pg_config 文件并在该文件下运行 gem install。
采纳答案by Tony
The trick was to install the pg gem under the correct pathway to pg_config whereas before it wasn't fully installed.
I ran gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
after locating the pg_config exec file. I just had to locate my pg_config file and run gem install under that pathway.
诀窍是在 pg_config 的正确路径下安装 pg gem,而在它没有完全安装之前。我gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
在找到 pg_config exec 文件后运行。我只需要找到我的 pg_config 文件并在该路径下运行 gem install 。
回答by Sergey Toy
You need to install libpq-dev before
你需要先安装 libpq-dev
回答by Yuri Toledo
in ubuntu 18.04, need to ran sudo apt install libpq-dev
在 ubuntu 18.04 中,需要运行 sudo apt install libpq-dev
回答by Kenny Evitt
For Windows and as-of version 0.13.0
of the pg
gem, you should be able to install it using something like the following:
对于Windows和AS-的版本0.13.0
中的pg
宝石,你应该能够使用像下面这样安装它:
subst X: "C:\Program Files\PostgreSQL.0"
gem install pg -- --with-pg=X:
subst X: /D
Then you can successfully run bundle install
and see the following line in the output:
然后就可以成功运行bundle install
并在输出中看到以下行:
Using pg (0.13.0)
instead of the errors.
而不是错误。
[This is the same answer as thisanswer to the related question Can't install pg gem on Windows.]
[这与此相关问题的答案相同,无法在 Windows 上安装 pg gem。]
回答by Hamfri
On ubuntu 18.04 run the following command
在 ubuntu 18.04 上运行以下命令
sudo apt update
sudo apt install libpq-dev