I'm trying to install the pg gem in order to work again with my rails projects. But I get this error:
我正在尝试安装pg gem以再次使用我的rails项目。但是我得到了这个错误:
Building native extensions. This could take a while... ERROR: Error installing pg: ERROR: Failed to build gem native extension.
建立本地扩展。这可能需要一段时间……错误:错误安装pg:错误:未能构建gem本机扩展。
/Users/jeanosorio/.rvm/rubies/ruby-2.0.0-p247/bin/ruby extconf.rb checking for pg_config... no No pg_config... trying anyway. If
building fails, please try again with --with-pg-config=/path/to/pg_config 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.
构建失败,请再次尝试——使用-pg-config=/path/to/pg_config检查libpq-fe.h…没有找不到“libpq-fe”。h头* extconf。由于某些原因,rb失败*无法创建Makefile,可能缺少必要的库和/或header。检查mkmf。更详细的日志文件。您可能需要配置选项。
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/jeanosorio/.rvm/rubies/ruby-2.0.0-p247/bin/ruby --with-pg --without-pg --with-pg-config --without-pg-config --with-pg_config --without-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}/
提供了配置选项:with-opt-dir——withoutopt -dir -包括-opt-dir -包含-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --。
Gem files will remain installed in /Users/jeanosorio/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/pg-0.17.0 for inspection. Results logged to /Users/jeanosorio/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/gems/2.0.0/gems/pg-0.17.0/ext/gem_make.out
Gem文件将继续安装在/用户/jeanosorio/.rvm/rubies/红宝石-2.0.0-p247/lib/红宝石/宝石/2.0.0/ Gem /pg-0.17.0进行检查。结果记录到/用户/ jeanosorio / .rvm /红宝石/ ruby-2.0.0-p247 / lib / ruby /宝石/ 2.0.0 /珠宝/ pg-0.17.0 / ext / gem_make.out
I tried everything I found on * but I still get this error.
我尝试了我在*上找到的所有东西,但是我仍然会得到这个错误。
If I try to install postgresql using brew I get the following waring:
如果我尝试使用brew来安装postgresql,我将得到以下警告:
Warning: postgresql-9.2.4 already installed, it's just not linked
警告:postgresql-9.2.4已经安装,只是没有链接。
If I try to link
如果我尝试链接。
brew link postgresql Linking /usr/local/Cellar/postgresql/9.2.4... Warning: Could not link postgresql. Unlinking...
brew link postgresql链接/ usr/local/cellar/postgresql/9.2.4…警告:不能链接postgresql。链接……
Error: Could not symlink file: /usr/local/Cellar/postgresql/9.2.4/share/man/man7/WITH.7 /usr/local/share/man/man7 is not writable. You should change its permissions.
错误:不能将文件链接到:/ usr/local/cellar/postgresql/9.2.4/share/man/man/man7/with。7 /usr/local/share/man/man7是不可写的。您应该更改其权限。
Help Please
请帮忙
NOTE: I already installed the command line tools for mavericks.
注意:我已经为mavericks安装了命令行工具。
If I uninstall using homebrew and try to install again, I get this error:
如果我使用homebrew卸载并重新安装,我就会得到这个错误:
==> Downloading http://ftp.postgresql.org/pub/source/v9.2.4/postgresql-9.2.4.tar.bz2
= = >下载http://ftp.postgresql.org/pub/source/v9.2.4/postgresql-9.2.4.tar.bz2
################################################################## 100.0%==> Patching patching file src/pl/plpython/Makefile patching file contrib/uuid-ossp/uuid-ossp.c ==> ./configure --prefix=/usr/local/Cellar/postgresql/9.2.4 --datadir=/usr/local/Cellar/postgresql/9.2.4/share/postgresql --docdir=/usr/local/Cellar/p ==> make install-world ==> Caveats
==>补丁修补文件src/pl/plpython/Makefile修补文件/uuid-ossp/uuid-ossp。c ==> ./configure -前缀=/usr/local/地窖/postgresql/9.2.4 -datadir=/usr/local/地窖/postgresql/9.2.4/共享/postgresql -docdir=/usr/local/地窖/p ==>,安装-world ==>警告。
Build Notes
If builds of PostgreSQL 9 are failing and you have version 8.x installed, you may need to remove the previous version first. See:
https://github.com/mxcl/homebrew/issues/issue/2510如果PostgreSQL 9的构建失败,而您有版本8。安装x后,您可能需要先删除之前的版本。参见:https://github.com/mxcl/homebrew/issues/issue/2510
Create/Upgrade a Database
If this is your first install, create a database with: initdb /usr/local/var/postgres -E utf8
如果这是您的第一个安装,请使用:initdb /usr/local/var/postgres - eutf8创建一个数据库。
To migrate existing data from a previous major version (pre-9.2) of PostgreSQL, see:
http://www.postgresql.org/docs/9.2/static/upgrading.html要迁移之前的主要版本(pre-9.2)的现有数据,请参见:http://www.postgresql.org/docs/9.2/static/upgrading.html。
Loading Extensions
By default, Homebrew builds all available Contrib extensions. To see a list of all available extensions, from the psql command line, run:
SELECT * FROM pg_available_extensions;默认情况下,Homebrew构建所有可用的设计扩展。要查看所有可用扩展的列表,从psql命令行运行:选择* from pg_available_extensions;
To load any of the extension names, navigate to the desired database and run: CREATE EXTENSION [extension name];
要加载任何扩展名,导航到所需的数据库并运行:创建扩展名[扩展名];
For instance, to load the tablefunc extension in the current database, run: CREATE EXTENSION tablefunc;
例如,要在当前数据库中加载tablefunc扩展,运行:创建扩展表func;
For more information on the CREATE EXTENSION command, see:
http://www.postgresql.org/docs/9.2/static/sql-createextension.html For more information on extensions, see:
http://www.postgresql.org/docs/9.2/static/contrib.html有关创建扩展命令的更多信息,请参见:http://www.postgresql.org/docs/9.2/static/sql-createextension.html以获得更多关于扩展的信息,请参见:http://www.postgresql.org/docs/9.2/static/schemb.html。
Other
Some machines may require provisioning of shared memory:
http://www.postgresql.org/docs/9.2/static/kernel-resources.html#SYSVIPC When installing the postgres gem, including ARCHFLAGS is recommended: ARCHFLAGS="-arch x86_64" gem install pg有些机器可能需要提供共享内存:http://www.postgresql.org/docs/9.2/static/kernresources.html #SYSVIPC,在安装postgres gem时,建议使用ARCHFLAGS: ARCHFLAGS="-arch x86_64" gem安装pg。
To install gems without sudo, see the Homebrew wiki.
要安装没有sudo的gems,请参阅Homebrew wiki。
To have launchd start postgresql at login: ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents Then to load postgresql now: launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist Or, if you don't want/need launchctl, you can just run: pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start Warning: Could not link postgresql. Unlinking... Error: The
brew link
step did not complete successfully The formula built, but is not symlinked into /usr/local You can try again using `brew link postgresql' ==> Summary ???? /usr/local/Cellar/postgresql/9.2.4: 2831 files, 38M, built in 4.9 minutes在登录时启动postgresql: ln -sfv / usr/local/opt/postgresql/。plist ~/Library/LaunchAgents然后加载postgresql: launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql。plist或者,如果您不需要launchctl,您可以运行:pg_ctl -D /usr/local/var/postgres -l / usr/local/var/postgres/server。日志开始警告:不能链接postgresql。链接……错误:brew链接步骤并没有成功地完成构建的公式,但它与/usr/local没有关系,您可以尝试再次使用“brew link postgresql”==> Summary /usr/local/Cellar/postgresql/9.2.4: 2831文件,3800米,构建于4.9分钟。
SOLUTION:
解决方案:
I execute this command in order to change the permission of the folder:
我执行此命令是为了更改文件夹的权限:
sudo chown jeanosorio /usr/local/share/man/man7
sudo乔恩jeanosorio /usr/local/share/man/man7
Then
然后
brew link postgresql Linking /usr/local/Cellar/postgresql/9.3.1... 421 symlinks created
brew link postgresql链接/ usr/local/cellar/postgresql/9.3.1…421年创建的符号链接
And finally:
最后:
sudo ARCHFLAGS="-arch x86_64" gem install pg
sudo ARCHFLAGS="-arch x86_64" gem安装pg。
Fetching: pg-0.17.0.gem (100%) Building native extensions. This could take a while... Successfully installed pg-0.17.0
抓取:pg-0.17.0。gem(100%)构建原生扩展。这可能需要一段时间……成功安装pg-0.17.0
27 个解决方案
#1
217
If you want to avoid using MacPorts, you can download the Postgres App and place it into the Application directory.
如果您想避免使用MacPorts,您可以下载Postgres应用程序并将其放置到应用程序目录中。
Then, specify the location of newly downloaded pg_config
:
然后,指定新下载的pg_config的位置:
gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/latest/bin/pg_config
If you run in to missing headers problem, try specifying the include
directory of the app:
如果您遇到了丢失的头问题,请尝试指定应用程序的include目录:
gem install pg -- --with-pg-include='/Applications/Postgres.app/Contents/Versions/latest/include/'
#2
65
Use brew to get postgresql
使用brew获取postgresql。
brew install postgresql
Check you have pg_config in the installed brew. I found mine in
检查在已安装的brew中是否有pg_config。我发现我在
/usr/local/Cellar/postgresql/9.3.3/bin/pg_config
/usr/local/Cellar/postgresql/9.3.3/bin/pg_config
Check via :
检查通过:
$ ls /usr/local/Cellar/postgresql/9.3.3/bin/pg_config
> /usr/local/Cellar/postgresql/9.3.3/bin/pg_config
Once done, install the pg
gem with
完成后,安装pg gem。
env ARCHFLAGS="-arch x86_64" gem install pg -- --with-pg-config=/usr/local/Cellar/postgresql/9.3.3/bin/pg_config
#3
35
I wasn't able to install postgres via MacPorts. Instead, I installed Postgress.app. and called
我无法通过MacPorts安装postgres。相反,我Postgress.app安装。,叫
gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/MacOS/bin/pg_config
Note: in newer versions (in 9.3 at least) the path is actually: /Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config
注意:在较新的版本(至少9.3)中,路径实际上是:/应用程序/Postgres.app/内容/版本/9.3/bin/pg_config。
#4
10
Here's another alternative in case you want to use the postgresql installer directly. There's a couple of hoops you gotta jump through to begin with after updating to mavericks. Here's what I did:
如果您想直接使用postgresql安装程序,这里还有另一种选择。在升级到小牛队之后,你需要跳上几圈。这是我所做的:
Install the xcode command line tools first:
首先安装xcode命令行工具:
xcode-select --install
Download and install the latest version of PostgreSQL (9.3.1), in my case I just used the graphical installer. Here's the link to the downloads page:
下载并安装最新版本的PostgreSQL(9.3.1),在我的例子中,我只是使用了图形安装程序。以下是下载页面的链接:
http://www.enterprisedb.com/products-services-training/pgdownload#osx
Just choose all of the defaults it gives you. It my case it installed postgres to the following directory, if you installed it to a different directory, just remember the path you chose, because you'll need it shortly.
只需要选择它给你的所有默认值。我的情况是,它将postgres安装到下面的目录中,如果您将它安装到一个不同的目录中,请记住您选择的路径,因为您很快就需要它。
/Library/PostgreSQL/9.3
If you now try and install the latest pg gem (0.17.0) you'll need to pass a couple of options on the command line. This is what I used:
如果您现在尝试安装最新的pg gem(0.17.0),您需要在命令行上传递几个选项。这就是我所使用的:
ARCHFLAGS="-arch x86_64" gem install pg -- --with-pg-config=/Library/PostgreSQL/9.3/bin/pg_config
If you installed postgres to a different location then you'll need to fix up the path to the pg_config file.
如果您将postgres安装到不同的位置,那么您将需要修复pg_config文件的路径。
If it complains of a missing 'libpq.5.dylib' file while trying install the pg gem you'll need to create a symlink pointing to the actual location of this file. Postgres is looking for it in your /usr/local/lib/ directory so create a symlink in there and redirect it to its actual location. In my case I had to run:
如果它抱怨缺少“libpq.5”。在尝试安装pg gem时,您需要创建一个指向该文件实际位置的符号链接。Postgres在您的/usr/local/lib/目录中查找它,因此在那里创建一个symlink并将其重定向到它的实际位置。在我的情况下,我必须跑:
sudo ln -s /Library/PostgreSQL/9.3/lib/libpq.5.dylib /usr/local/lib/libpq.5.dylib
Once you've done that, retry installing the gem again and hopefully it will work for you the same way it did for me.
一旦你这样做了,重新安装gem,希望它能像我一样为你工作。
#5
8
If you have homebrew, just type:
如果你有家酿啤酒,请输入:
$ brew install postgresql
酿造安装postgresql美元
#6
6
For me, on Yosemite, I didn't need to specify pg_config
path. The following got it done.
对于我来说,在Yosemite上,我不需要指定pg_config路径。下面就完成了。
brew install postgresql
sudo env ARCHFLAGS="-arch x86_64" gem install pg
Seems like architecture flag is the key.
似乎架构标志是关键。
#7
5
Place the missing --with-pg-config
in Bundler's config file: /Users/<your_user>/.bundle/config
to make your life easier.
在Bundler的配置文件中放置缺失的-pg-config: /Users/
---
BUNDLE_BUILD__PG: --with-pg-config=/Applications/Postgres93.app/Contents/MacOS/bin/pg_config
BUNDLE_BUILD__EXAMPLE_GEM: --other-configs
BUNDLE_BUILD__OTHER_EXAMPLE_GEM: --other-configs
Then run bundle install
again.
然后再运行bundle安装。
#8
5
That works for me! (Postgres 93, mac ox 10.9.1)1. download @ http://postgresapp.com/ and than
那适合我!(Postgres 93, mac ox 10.9.1)1。下载@ postgresapp.com/,而不是。
gem install pg -- --with-pg-config=/Applications/Postgres93.app/Contents/MacOS/bin/pg_config
#9
4
In my case (i needed PG 0.16.0 on Mavericks), i installed postgresql via MacPorts
在我的例子中(在Mavericks上我需要PG 0.16.0),我通过MacPorts安装了postgresql。
sudo port install postgresql90
and then
然后
gem install pg -v '0.16.0' -- --with-pg-config=/opt/local/lib/postgresql90/bin/pg_config
For the latest version you need to deduct -v '0.16.0'
对于最新版本,你需要扣除-v '0.16.0'
gem install pg -- --with-pg-config=/opt/local/lib/postgresql90/bin/pg_config
If you have Homebrew installed do not install MacPorts before you read about their coexistense
如果你已经安装了Homebrew,在你阅读他们的coexistense之前不要安装MacPorts。
#10
4
I was stuck on my bundle install for 3 days. Tried Everything like adding env ARCHFLAGS="-arch x86_64" gem install pg -- --with-pg-config=/usr/local/Cellar/postgresql/9.3.5_1/bin/pg_config
我被困在我的包里3天了。尝试了所有的操作,比如添加env ARCHFLAGS="-arch x86_64" gem安装pg -- -- -- -with-pg-config=/usr/local/Cellar/postgresql/9.3.5_1/bin/pg_config。
I was able to see pg gem getting installed after this command but still it was not installing from bundle install, which was a pain because I dint know what to write in Gemfile except gem 'pg'
我可以看到在这个命令之后安装了pg gem但是仍然没有安装从bundle安装,这很痛苦因为我不知道在Gemfile中写什么除了gem 'pg'
The thing which finally worked for me was to find that my pg_config was in /Library/PostgreSQL/9.3/bin/pg_config and by default the Gemfile bundle install looks in /usr/local/bin/pg_config
最后,我发现我的pg_config在/Library/PostgreSQL/9.3/bin/pg_config中,默认情况下,Gemfile包安装在/usr/local/bin/pg_config中。
I just ran the following command and magic happened. bundle config build.pg --with-pg-config=/Library/PostgreSQL/9.3/bin/pg_config
我只是运行了下面的命令和魔法。包配置构建。pg - with-pg-config = /图书馆/ PostgreSQL / 9.3 / bin / pg_config
#11
4
In my case it didn't work if you don't specify the arch flags, OS X 10.10.3 and postersApp 9.4
在我的例子中,如果你不指定arch标志,OS X 10.10.3和postersApp 9.4,它就不工作了。
sudo env ARCHFLAGS="-arch x86_64" gem install pg -- \--with-pg-config=/Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config
#12
2
This is what it worked for me:
这就是它对我的作用:
gem install pg -- --with-pg-config=/Library/PostgreSQL/9.3/bin/pg_config
#13
2
In my case, I uninstalled the version installed via homebrew and switched to Postgres.app (v9.3.4.2 at the time of writing).
在我的例子中,我卸载了通过自制程序安装的版本,然后切换到Postgres。app(写作时v9.3.4.2)。
It only seemed to work when prepending the environment architecture flags and specifying the path to pg_config
. Your milage might vary, so this answer could help with variations on pg_config
's location.
它似乎只在环境架构标志和指定pg_config路径的时候起作用。您的milage可能会有所不同,所以这个答案可能有助于pg_config的位置的变化。
Here is the final, complete command that worked for me:
下面是我的最后一个完整的命令:
env ARCHFLAGS="-arch x86_64" gem install pg -- \
--with-pg-config=/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config
#14
2
sudo ARCHFLAGS="-arch x86_64" gem install pg -- --with-pg-config=/usr/local/bin/pg_config
sudo ARCHFLAGS="-arch x86_64" gem安装pg -- -使用-pg-config=/usr/local/bin/pg_config。
#15
1
I was getting the same error when running bundle install regarding the pg gem (using Mac OS X Mavericks). After hours of researching, I found the solution. I installed postgres using homebrew
在使用pg gem(使用Mac OS X Mavericks)时,我遇到了相同的错误。经过几个小时的研究,我找到了解决办法。我用自制软件安装了postgres。
brew install postgres
After installing that, I created a new rails app using postgres. I ran
安装之后,我使用postgres创建了一个新的rails应用程序。我跑
bundle install
to no avail (got same error as the question). I used
毫无用处(与问题有相同的错误)。我使用
which psql
to figure out where my postgres was installed, it returned
为了找出我的postgres安装在哪里,它返回了。
/usr/local/bin/psql
before running bundle install again, I had to change the global path to build.pg by running the following
在运行bundle安装之前,我必须改变全局路径来构建。通过运行下面的操作。
bundle config build.pg --with-pg-config=/usr/local/bin/pg_config
then I ran bundle install again and voila! I used the postgres where brew installed it.
然后我再次运行bundle安装,瞧!我用的是brew的postgres。
#16
1
On OS X Mavericks with latest Postgres App do the following with sudo privileges
在OS X Mavericks上,最新的Postgres应用程序使用sudo特权执行以下操作。
env ARCHFLAGS="-arch x86_64" gem install pg -v '0.17.1' -- --with-pg-config=/Applications/Postgres.app/Contents/MacOS/bin/pg_config
#17
1
What worked for me on 10.9.3 with Xcode 5.1.1 was the following:
在10.9.3与Xcode 5.1.1中,我所做的工作如下:
brew update
brew install postgresql
gem install pg -v '0.17.1'
I needed pg 0.17.1
我需要pg 0.17.1
#18
1
For any lost soul outthere still having this issue with no resolution and have a brew
installed ruby and postgres. Here's the following steps to make sure of:
对于任何失去的灵魂,仍然有这个问题没有解决,并有一个brew安装ruby和postgres。以下是确保:
- Make sure your version of
ruby
wasn't installed with the--universal
flag.- This was the hardest thing to figure out, I had
--universal
which was the final root of the problem. - 这是最难搞清楚的,我有——环球,这是问题的最终根源。
- This was the hardest thing to figure out, I had
- 请确保您的ruby版本没有安装通用标志。这是最难搞清楚的,我有——环球,这是问题的最终根源。
- Make sure you have initialized
postgresql
properly withinitdb
andcreatedb
commands (look elsewhere for steps to do this). - 确保您已经正确地使用initdb和createdb命令初始化了postgresql(请查看其他步骤以执行此操作)。
- Make sure
Xcode
(Optional) andcommand line tools
is installed; on the terminal:xcode-select --install
- xcode-select——安装
-
sudo xcodebuild -license
(if Xcode installed) or open the application and accept the license agreement. - sudo xcodebuild -license(如果安装了Xcode)或打开应用程序并接受许可协议。
- Reboot Computer
- 重新启动计算机
- 确保安装了Xcode(可选)和命令行工具;在终端:Xcode -select—安装sudo xcodebuild -license(如果安装了Xcode)或打开应用程序并接受许可协议。重新启动计算机
-
which ruby
,which gem
andwhich postgres
should show/usr/local/bin/ruby
,/usr/local/bin/gem
and/usr/local/bin/postgres
respectfully. - 哪个ruby,哪个gem,哪个postgres应该显示/usr/local/bin/ruby, /usr/local/bin/gem和/usr/local/bin/postgres。
-
On the terminal run:
在终端运行:
gem install pg -- --with-pg-config=/usr/local/bin/pg_config
- gem安装pg -- -配置=/usr/local/bin/pg_config。
- or
- 或
env ARCHFLAGS="-arch x86_64" gem install pg -- --with-pg-config=/usr/local/bin/pg_config
- env ARCHFLAGS="-arch x86_64" gem安装pg -- -使用-pg-config=/usr/local/bin/pg_config。
-
Making sure all these steps are satisfied I was able to solve the following errors:
确保所有这些步骤都得到满足,我能够解决以下错误:
-
ruby.h
header error - ruby。h标题错误
-
developer tools installed first
error - 开发工具安装了第一个错误。
-
#19
1
The easiest way for me to resolve this was to use Postgres.app and set up my env vars so gem install pg
just works (instead of requiring the --with-pg-config
flag).
我解决这个问题最简单的方法就是使用Postgres。应用程序和设置我的env vars,所以gem安装pg只是工作(而不是要求-使用-pg配置标志)。
Using Homebrew Cask,
使用自酿酒桶,
brew cask install postgres
echo 'export PG_HOME=/Applications/Postgres.app/Contents/Versions/latest' >> ~/.bash_profile
echo 'export PATH="$PATH:$PG_HOME/bin"' >> ~/.bash_profile
source ~/.bash_profile
# now it just works
gem install pg
#20
0
I was with the same problem, this was the solution I've found.
我遇到了同样的问题,这是我找到的解决方法。
If you run brew doctor
, it will tell you that probably you have installed something without brew that have changed the permissions on some folders, and so, you need to change permissions back to you on that folder.
如果您运行brew doctor,它会告诉您,您可能已经安装了一些没有brew的东西,它们已经更改了某些文件夹的权限,因此,您需要在该文件夹上更改权限。
Inside /usr/local/share/man
, what you can do is the following:
在/usr/local/share/man中,你可以做以下事情:
sudo chown [yourusername] man7
sudo乔恩yourusername man7
And then:
然后:
brew link postgres
酿造postgres的联系
Hope it helps!
希望它可以帮助!
#21
0
Similarly, after installing Mavericks 'bundle update' was throwing an error on the pg gem, which is only used on production and not locally.
类似地,在安装了Mavericks的bundle update之后,在pg gem上抛出了一个错误,该错误只用于生产,而不是本地。
I use Brew to manage my packages and postgresql was already installed, but still I was getting the 'no pg_config' error.
我使用Brew来管理我的包,postgresql已经安装好了,但我还是得到了“no pg_config”错误。
The fix was to just 'brew uninstall postgresql', then 'brew install postgresql'. After which I was immediately able to successfully run 'bundle update'
解决方案是“brew uninstall postgresql”,然后“brew安装postgresql”。之后,我就可以成功地运行“bundle update”
#22
0
sudo su
then
然后
ARCHFLAGS="-arch x86_64" gem install pg -v '0.18'
worked on 10.10.2
从事10.10.2
#23
0
If after trying everything here it still won't install, try opening Xcode and accepting the license agreement.
如果在这里尝试了所有东西,它仍然不会安装,尝试打开Xcode并接受许可协议。
#24
0
For me, the error message looked like this:
对我来说,错误信息是这样的:
Installing pg 0.18.4 with native extensions
使用原生扩展安装pg 0.18.4。
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
:BuildError: ERROR:未能构建Gem本机扩展。
...
…
checking for pg_config... no
检查pg_config……没有
No pg_config... trying anyway. If building fails, please try again with --with-pg-config=/path/to/pg_config
没有pg_config…不管怎样。如果构建失败,请再次尝试使用—with-pg-config=/path/to/pg_config。
As the error message shows, it's trying to execute the command/script "pg_config". So just add it to the path from wherever your Postgres installation is. In my case, I did:
正如错误消息所显示的,它正在尝试执行命令/脚本“pg_config”。所以只要把它添加到你的Postgres安装的路径。在我的案例中,我做到了:
export PATH=/Applications/Postgres.app/Contents/Versions/9.5/bin:$PATH
导出路径= /应用程序/ Postgres.app /内容/版本/ 9.5 / bin:美元的道路
then
然后
bundle
包
That's it.
就是这样。
#25
0
First of all find pg_config location
首先找到pg_config位置。
sudo find / -name "pg_config" -print
The answer is /Library/PostgreSQL/9.1/bin/pg_config in my configuration (MAC Maverick)
答案是/Library/PostgreSQL/9.1/bin/pg_config在我的配置中(MAC Maverick)
Then try installing something like below
然后尝试安装如下的东西。
gem install pg -- --with-pg-config=/Library/PostgreSQL/9.3/bin/pg_config
gem安装pg -- -- -配置=/库/PostgreSQL/9.3/bin/pg_config。
if this does not work then try to check in what way you installed postgresql
如果这个方法不起作用,那么尝试检查您安装postgresql的方式。
brew/mac port/setup
啤酒/ mac端口设置
then you have to try relevant option to the same.
然后你必须尝试相关的选项。
Thank you.
谢谢你!
Ram
内存
#26
-1
Postgres worked for me as well. (Postgres 93, mac ox 10.9.1)1. download @ http://postgresapp.com/ and then
Postgres也为我工作。(Postgres 93, mac ox 10.9.1)1。下载@ postgresapp.com/然后。
gem install pg -- --with-pg-config=/Applications/Postgres93.app/Contents/MacOS/bin/pg_config
It's really important to make sure you get the version number right in the Postgres folder name.
确保在Postgres文件夹名中获得版本号是非常重要的。
Also, I tried this fix in another app and I kept getting an error that wanted a specific version of PG (in my case 0.16.0) so I had to add -v '0.16.0' to my command.
另外,我在另一个应用程序中尝试了这个补丁,我不断得到一个错误,想要一个特定版本的PG(在我的例子中是0.16.0),所以我必须在我的命令中添加-v '0.16.0'。
#27
-1
Postgres 9.4:
Postgres 9.4:
gem install pg -- --with-pg-config=/Applications/Postgres93.app/Contents/Versions/9.4/bin/pg_config
#1
217
If you want to avoid using MacPorts, you can download the Postgres App and place it into the Application directory.
如果您想避免使用MacPorts,您可以下载Postgres应用程序并将其放置到应用程序目录中。
Then, specify the location of newly downloaded pg_config
:
然后,指定新下载的pg_config的位置:
gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/latest/bin/pg_config
If you run in to missing headers problem, try specifying the include
directory of the app:
如果您遇到了丢失的头问题,请尝试指定应用程序的include目录:
gem install pg -- --with-pg-include='/Applications/Postgres.app/Contents/Versions/latest/include/'
#2
65
Use brew to get postgresql
使用brew获取postgresql。
brew install postgresql
Check you have pg_config in the installed brew. I found mine in
检查在已安装的brew中是否有pg_config。我发现我在
/usr/local/Cellar/postgresql/9.3.3/bin/pg_config
/usr/local/Cellar/postgresql/9.3.3/bin/pg_config
Check via :
检查通过:
$ ls /usr/local/Cellar/postgresql/9.3.3/bin/pg_config
> /usr/local/Cellar/postgresql/9.3.3/bin/pg_config
Once done, install the pg
gem with
完成后,安装pg gem。
env ARCHFLAGS="-arch x86_64" gem install pg -- --with-pg-config=/usr/local/Cellar/postgresql/9.3.3/bin/pg_config
#3
35
I wasn't able to install postgres via MacPorts. Instead, I installed Postgress.app. and called
我无法通过MacPorts安装postgres。相反,我Postgress.app安装。,叫
gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/MacOS/bin/pg_config
Note: in newer versions (in 9.3 at least) the path is actually: /Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config
注意:在较新的版本(至少9.3)中,路径实际上是:/应用程序/Postgres.app/内容/版本/9.3/bin/pg_config。
#4
10
Here's another alternative in case you want to use the postgresql installer directly. There's a couple of hoops you gotta jump through to begin with after updating to mavericks. Here's what I did:
如果您想直接使用postgresql安装程序,这里还有另一种选择。在升级到小牛队之后,你需要跳上几圈。这是我所做的:
Install the xcode command line tools first:
首先安装xcode命令行工具:
xcode-select --install
Download and install the latest version of PostgreSQL (9.3.1), in my case I just used the graphical installer. Here's the link to the downloads page:
下载并安装最新版本的PostgreSQL(9.3.1),在我的例子中,我只是使用了图形安装程序。以下是下载页面的链接:
http://www.enterprisedb.com/products-services-training/pgdownload#osx
Just choose all of the defaults it gives you. It my case it installed postgres to the following directory, if you installed it to a different directory, just remember the path you chose, because you'll need it shortly.
只需要选择它给你的所有默认值。我的情况是,它将postgres安装到下面的目录中,如果您将它安装到一个不同的目录中,请记住您选择的路径,因为您很快就需要它。
/Library/PostgreSQL/9.3
If you now try and install the latest pg gem (0.17.0) you'll need to pass a couple of options on the command line. This is what I used:
如果您现在尝试安装最新的pg gem(0.17.0),您需要在命令行上传递几个选项。这就是我所使用的:
ARCHFLAGS="-arch x86_64" gem install pg -- --with-pg-config=/Library/PostgreSQL/9.3/bin/pg_config
If you installed postgres to a different location then you'll need to fix up the path to the pg_config file.
如果您将postgres安装到不同的位置,那么您将需要修复pg_config文件的路径。
If it complains of a missing 'libpq.5.dylib' file while trying install the pg gem you'll need to create a symlink pointing to the actual location of this file. Postgres is looking for it in your /usr/local/lib/ directory so create a symlink in there and redirect it to its actual location. In my case I had to run:
如果它抱怨缺少“libpq.5”。在尝试安装pg gem时,您需要创建一个指向该文件实际位置的符号链接。Postgres在您的/usr/local/lib/目录中查找它,因此在那里创建一个symlink并将其重定向到它的实际位置。在我的情况下,我必须跑:
sudo ln -s /Library/PostgreSQL/9.3/lib/libpq.5.dylib /usr/local/lib/libpq.5.dylib
Once you've done that, retry installing the gem again and hopefully it will work for you the same way it did for me.
一旦你这样做了,重新安装gem,希望它能像我一样为你工作。
#5
8
If you have homebrew, just type:
如果你有家酿啤酒,请输入:
$ brew install postgresql
酿造安装postgresql美元
#6
6
For me, on Yosemite, I didn't need to specify pg_config
path. The following got it done.
对于我来说,在Yosemite上,我不需要指定pg_config路径。下面就完成了。
brew install postgresql
sudo env ARCHFLAGS="-arch x86_64" gem install pg
Seems like architecture flag is the key.
似乎架构标志是关键。
#7
5
Place the missing --with-pg-config
in Bundler's config file: /Users/<your_user>/.bundle/config
to make your life easier.
在Bundler的配置文件中放置缺失的-pg-config: /Users/
---
BUNDLE_BUILD__PG: --with-pg-config=/Applications/Postgres93.app/Contents/MacOS/bin/pg_config
BUNDLE_BUILD__EXAMPLE_GEM: --other-configs
BUNDLE_BUILD__OTHER_EXAMPLE_GEM: --other-configs
Then run bundle install
again.
然后再运行bundle安装。
#8
5
That works for me! (Postgres 93, mac ox 10.9.1)1. download @ http://postgresapp.com/ and than
那适合我!(Postgres 93, mac ox 10.9.1)1。下载@ postgresapp.com/,而不是。
gem install pg -- --with-pg-config=/Applications/Postgres93.app/Contents/MacOS/bin/pg_config
#9
4
In my case (i needed PG 0.16.0 on Mavericks), i installed postgresql via MacPorts
在我的例子中(在Mavericks上我需要PG 0.16.0),我通过MacPorts安装了postgresql。
sudo port install postgresql90
and then
然后
gem install pg -v '0.16.0' -- --with-pg-config=/opt/local/lib/postgresql90/bin/pg_config
For the latest version you need to deduct -v '0.16.0'
对于最新版本,你需要扣除-v '0.16.0'
gem install pg -- --with-pg-config=/opt/local/lib/postgresql90/bin/pg_config
If you have Homebrew installed do not install MacPorts before you read about their coexistense
如果你已经安装了Homebrew,在你阅读他们的coexistense之前不要安装MacPorts。
#10
4
I was stuck on my bundle install for 3 days. Tried Everything like adding env ARCHFLAGS="-arch x86_64" gem install pg -- --with-pg-config=/usr/local/Cellar/postgresql/9.3.5_1/bin/pg_config
我被困在我的包里3天了。尝试了所有的操作,比如添加env ARCHFLAGS="-arch x86_64" gem安装pg -- -- -- -with-pg-config=/usr/local/Cellar/postgresql/9.3.5_1/bin/pg_config。
I was able to see pg gem getting installed after this command but still it was not installing from bundle install, which was a pain because I dint know what to write in Gemfile except gem 'pg'
我可以看到在这个命令之后安装了pg gem但是仍然没有安装从bundle安装,这很痛苦因为我不知道在Gemfile中写什么除了gem 'pg'
The thing which finally worked for me was to find that my pg_config was in /Library/PostgreSQL/9.3/bin/pg_config and by default the Gemfile bundle install looks in /usr/local/bin/pg_config
最后,我发现我的pg_config在/Library/PostgreSQL/9.3/bin/pg_config中,默认情况下,Gemfile包安装在/usr/local/bin/pg_config中。
I just ran the following command and magic happened. bundle config build.pg --with-pg-config=/Library/PostgreSQL/9.3/bin/pg_config
我只是运行了下面的命令和魔法。包配置构建。pg - with-pg-config = /图书馆/ PostgreSQL / 9.3 / bin / pg_config
#11
4
In my case it didn't work if you don't specify the arch flags, OS X 10.10.3 and postersApp 9.4
在我的例子中,如果你不指定arch标志,OS X 10.10.3和postersApp 9.4,它就不工作了。
sudo env ARCHFLAGS="-arch x86_64" gem install pg -- \--with-pg-config=/Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config
#12
2
This is what it worked for me:
这就是它对我的作用:
gem install pg -- --with-pg-config=/Library/PostgreSQL/9.3/bin/pg_config
#13
2
In my case, I uninstalled the version installed via homebrew and switched to Postgres.app (v9.3.4.2 at the time of writing).
在我的例子中,我卸载了通过自制程序安装的版本,然后切换到Postgres。app(写作时v9.3.4.2)。
It only seemed to work when prepending the environment architecture flags and specifying the path to pg_config
. Your milage might vary, so this answer could help with variations on pg_config
's location.
它似乎只在环境架构标志和指定pg_config路径的时候起作用。您的milage可能会有所不同,所以这个答案可能有助于pg_config的位置的变化。
Here is the final, complete command that worked for me:
下面是我的最后一个完整的命令:
env ARCHFLAGS="-arch x86_64" gem install pg -- \
--with-pg-config=/Applications/Postgres.app/Contents/Versions/9.3/bin/pg_config
#14
2
sudo ARCHFLAGS="-arch x86_64" gem install pg -- --with-pg-config=/usr/local/bin/pg_config
sudo ARCHFLAGS="-arch x86_64" gem安装pg -- -使用-pg-config=/usr/local/bin/pg_config。
#15
1
I was getting the same error when running bundle install regarding the pg gem (using Mac OS X Mavericks). After hours of researching, I found the solution. I installed postgres using homebrew
在使用pg gem(使用Mac OS X Mavericks)时,我遇到了相同的错误。经过几个小时的研究,我找到了解决办法。我用自制软件安装了postgres。
brew install postgres
After installing that, I created a new rails app using postgres. I ran
安装之后,我使用postgres创建了一个新的rails应用程序。我跑
bundle install
to no avail (got same error as the question). I used
毫无用处(与问题有相同的错误)。我使用
which psql
to figure out where my postgres was installed, it returned
为了找出我的postgres安装在哪里,它返回了。
/usr/local/bin/psql
before running bundle install again, I had to change the global path to build.pg by running the following
在运行bundle安装之前,我必须改变全局路径来构建。通过运行下面的操作。
bundle config build.pg --with-pg-config=/usr/local/bin/pg_config
then I ran bundle install again and voila! I used the postgres where brew installed it.
然后我再次运行bundle安装,瞧!我用的是brew的postgres。
#16
1
On OS X Mavericks with latest Postgres App do the following with sudo privileges
在OS X Mavericks上,最新的Postgres应用程序使用sudo特权执行以下操作。
env ARCHFLAGS="-arch x86_64" gem install pg -v '0.17.1' -- --with-pg-config=/Applications/Postgres.app/Contents/MacOS/bin/pg_config
#17
1
What worked for me on 10.9.3 with Xcode 5.1.1 was the following:
在10.9.3与Xcode 5.1.1中,我所做的工作如下:
brew update
brew install postgresql
gem install pg -v '0.17.1'
I needed pg 0.17.1
我需要pg 0.17.1
#18
1
For any lost soul outthere still having this issue with no resolution and have a brew
installed ruby and postgres. Here's the following steps to make sure of:
对于任何失去的灵魂,仍然有这个问题没有解决,并有一个brew安装ruby和postgres。以下是确保:
- Make sure your version of
ruby
wasn't installed with the--universal
flag.- This was the hardest thing to figure out, I had
--universal
which was the final root of the problem. - 这是最难搞清楚的,我有——环球,这是问题的最终根源。
- This was the hardest thing to figure out, I had
- 请确保您的ruby版本没有安装通用标志。这是最难搞清楚的,我有——环球,这是问题的最终根源。
- Make sure you have initialized
postgresql
properly withinitdb
andcreatedb
commands (look elsewhere for steps to do this). - 确保您已经正确地使用initdb和createdb命令初始化了postgresql(请查看其他步骤以执行此操作)。
- Make sure
Xcode
(Optional) andcommand line tools
is installed; on the terminal:xcode-select --install
- xcode-select——安装
-
sudo xcodebuild -license
(if Xcode installed) or open the application and accept the license agreement. - sudo xcodebuild -license(如果安装了Xcode)或打开应用程序并接受许可协议。
- Reboot Computer
- 重新启动计算机
- 确保安装了Xcode(可选)和命令行工具;在终端:Xcode -select—安装sudo xcodebuild -license(如果安装了Xcode)或打开应用程序并接受许可协议。重新启动计算机
-
which ruby
,which gem
andwhich postgres
should show/usr/local/bin/ruby
,/usr/local/bin/gem
and/usr/local/bin/postgres
respectfully. - 哪个ruby,哪个gem,哪个postgres应该显示/usr/local/bin/ruby, /usr/local/bin/gem和/usr/local/bin/postgres。
-
On the terminal run:
在终端运行:
gem install pg -- --with-pg-config=/usr/local/bin/pg_config
- gem安装pg -- -配置=/usr/local/bin/pg_config。
- or
- 或
env ARCHFLAGS="-arch x86_64" gem install pg -- --with-pg-config=/usr/local/bin/pg_config
- env ARCHFLAGS="-arch x86_64" gem安装pg -- -使用-pg-config=/usr/local/bin/pg_config。
-
Making sure all these steps are satisfied I was able to solve the following errors:
确保所有这些步骤都得到满足,我能够解决以下错误:
-
ruby.h
header error - ruby。h标题错误
-
developer tools installed first
error - 开发工具安装了第一个错误。
-
#19
1
The easiest way for me to resolve this was to use Postgres.app and set up my env vars so gem install pg
just works (instead of requiring the --with-pg-config
flag).
我解决这个问题最简单的方法就是使用Postgres。应用程序和设置我的env vars,所以gem安装pg只是工作(而不是要求-使用-pg配置标志)。
Using Homebrew Cask,
使用自酿酒桶,
brew cask install postgres
echo 'export PG_HOME=/Applications/Postgres.app/Contents/Versions/latest' >> ~/.bash_profile
echo 'export PATH="$PATH:$PG_HOME/bin"' >> ~/.bash_profile
source ~/.bash_profile
# now it just works
gem install pg
#20
0
I was with the same problem, this was the solution I've found.
我遇到了同样的问题,这是我找到的解决方法。
If you run brew doctor
, it will tell you that probably you have installed something without brew that have changed the permissions on some folders, and so, you need to change permissions back to you on that folder.
如果您运行brew doctor,它会告诉您,您可能已经安装了一些没有brew的东西,它们已经更改了某些文件夹的权限,因此,您需要在该文件夹上更改权限。
Inside /usr/local/share/man
, what you can do is the following:
在/usr/local/share/man中,你可以做以下事情:
sudo chown [yourusername] man7
sudo乔恩yourusername man7
And then:
然后:
brew link postgres
酿造postgres的联系
Hope it helps!
希望它可以帮助!
#21
0
Similarly, after installing Mavericks 'bundle update' was throwing an error on the pg gem, which is only used on production and not locally.
类似地,在安装了Mavericks的bundle update之后,在pg gem上抛出了一个错误,该错误只用于生产,而不是本地。
I use Brew to manage my packages and postgresql was already installed, but still I was getting the 'no pg_config' error.
我使用Brew来管理我的包,postgresql已经安装好了,但我还是得到了“no pg_config”错误。
The fix was to just 'brew uninstall postgresql', then 'brew install postgresql'. After which I was immediately able to successfully run 'bundle update'
解决方案是“brew uninstall postgresql”,然后“brew安装postgresql”。之后,我就可以成功地运行“bundle update”
#22
0
sudo su
then
然后
ARCHFLAGS="-arch x86_64" gem install pg -v '0.18'
worked on 10.10.2
从事10.10.2
#23
0
If after trying everything here it still won't install, try opening Xcode and accepting the license agreement.
如果在这里尝试了所有东西,它仍然不会安装,尝试打开Xcode并接受许可协议。
#24
0
For me, the error message looked like this:
对我来说,错误信息是这样的:
Installing pg 0.18.4 with native extensions
使用原生扩展安装pg 0.18.4。
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
:BuildError: ERROR:未能构建Gem本机扩展。
...
…
checking for pg_config... no
检查pg_config……没有
No pg_config... trying anyway. If building fails, please try again with --with-pg-config=/path/to/pg_config
没有pg_config…不管怎样。如果构建失败,请再次尝试使用—with-pg-config=/path/to/pg_config。
As the error message shows, it's trying to execute the command/script "pg_config". So just add it to the path from wherever your Postgres installation is. In my case, I did:
正如错误消息所显示的,它正在尝试执行命令/脚本“pg_config”。所以只要把它添加到你的Postgres安装的路径。在我的案例中,我做到了:
export PATH=/Applications/Postgres.app/Contents/Versions/9.5/bin:$PATH
导出路径= /应用程序/ Postgres.app /内容/版本/ 9.5 / bin:美元的道路
then
然后
bundle
包
That's it.
就是这样。
#25
0
First of all find pg_config location
首先找到pg_config位置。
sudo find / -name "pg_config" -print
The answer is /Library/PostgreSQL/9.1/bin/pg_config in my configuration (MAC Maverick)
答案是/Library/PostgreSQL/9.1/bin/pg_config在我的配置中(MAC Maverick)
Then try installing something like below
然后尝试安装如下的东西。
gem install pg -- --with-pg-config=/Library/PostgreSQL/9.3/bin/pg_config
gem安装pg -- -- -配置=/库/PostgreSQL/9.3/bin/pg_config。
if this does not work then try to check in what way you installed postgresql
如果这个方法不起作用,那么尝试检查您安装postgresql的方式。
brew/mac port/setup
啤酒/ mac端口设置
then you have to try relevant option to the same.
然后你必须尝试相关的选项。
Thank you.
谢谢你!
Ram
内存
#26
-1
Postgres worked for me as well. (Postgres 93, mac ox 10.9.1)1. download @ http://postgresapp.com/ and then
Postgres也为我工作。(Postgres 93, mac ox 10.9.1)1。下载@ postgresapp.com/然后。
gem install pg -- --with-pg-config=/Applications/Postgres93.app/Contents/MacOS/bin/pg_config
It's really important to make sure you get the version number right in the Postgres folder name.
确保在Postgres文件夹名中获得版本号是非常重要的。
Also, I tried this fix in another app and I kept getting an error that wanted a specific version of PG (in my case 0.16.0) so I had to add -v '0.16.0' to my command.
另外,我在另一个应用程序中尝试了这个补丁,我不断得到一个错误,想要一个特定版本的PG(在我的例子中是0.16.0),所以我必须在我的命令中添加-v '0.16.0'。
#27
-1
Postgres 9.4:
Postgres 9.4:
gem install pg -- --with-pg-config=/Applications/Postgres93.app/Contents/Versions/9.4/bin/pg_config