postgresql sudo gem install pg 不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4564117/
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
sudo gem install pg won't work
提问by Jason Swett
I'm trying to get Rails to work with PostgreSQL. Apparently one thing I need to do along the way is sudo gem install pg
. When I do that, I get this:
我正在尝试让 Rails 与 PostgreSQL 一起工作。显然,在此过程中我需要做的一件事是sudo gem install pg
. 当我这样做时,我得到了这个:
jason@buster:~/projects$ sudo gem install pg
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.8 extconf.rb
extconf.rb:2:in `require': no such file to load -- mkmf (LoadError)
from extconf.rb:2
Gem files will remain installed in /var/lib/gems/1.8/gems/pg-0.10.0 for inspection.
Results logged to /var/lib/gems/1.8/gems/pg-0.10.0/ext/gem_make.out
I've Googled and tried a few things based on what I've found but nothing seems to help. Any advice? I'm on Ubuntu.
我已经谷歌搜索并根据我发现的内容尝试了一些东西,但似乎没有任何帮助。有什么建议吗?我在 Ubuntu 上。
回答by Mereghost
You need to install your distro ruby-dev (or devel) package otherwise you won~t be able to build any ruby C extensions.
您需要安装发行版 ruby-dev(或 devel)软件包,否则您将无法构建任何 ruby C 扩展。
I'm not on ubuntu, but you package-manager command might be somewhat like this:
我不在 ubuntu 上,但你的 package-manager 命令可能有点像这样:
$ sudo apt-get install ruby-dev build-essential
回答by yfeldblum
On Ubuntu:
在 Ubuntu 上:
$ sudo apt-get install postgresql-client libpq5 libpq-dev
$ sudo gem install pg