我需要在雪豹上安装gem pg,因为我正在Rails代码库上运行rake.我不使用postgres.
I need to install gem pg on snow leopard because I am running rake on rails codebase. I am not using postgres.
这是我遇到的错误.
$ sudo gem install pg Password: Sorry, try again. Password: Building native extensions. This could take a while... ERROR: Error installing pg: ERROR: Failed to build gem native extension.查看了Google搜索中的各种博客,但没有一个起作用.
looked at various blogs from google search but none of them work.
推荐答案您可能必须指定您的CPU体系结构.首先,运行以下命令查看您正在运行的体系结构:
You may have to specify your CPU architecture. First, run the following to see which architecture you're running on:
(注意:将"/usr/bin/ruby"替换为哪个红宝石"返回).
(Note: Replace '/usr/bin/ruby' with whatever 'which ruby' returns).
$ lipo -detailed_info /usr/bin/ruby在那里,您应该会看到有关体系结构的内容(查找"i386"或"x86_64")
In there, you should see something about your architecture (look for 'i386' or 'x86_64')
如果这不起作用,请尝试以下操作:
If that doesn't work, try the following:
$ irb ['foo'].pack('p').size如果Ruby以64位运行,则结果为'8',如果以32位运行,则结果为'4'.
The result will be '8' if Ruby is running as 64-bit, or '4' if it's running in 32-bit.
然后,当您要安装Postgres gem时,请指定适当的体系结构:
Then, when you go to install the Postgres gem, specify the appropriate architecture:
$ sudo env ARCHFLAGS="-arch i386" gem install pg或者,
$ sudo env ARCHFLAGS="-arch x86_64" gem install pg如果您使用64位CPU运行Snow Leopard,则可能正在运行64位版本. 但是仍然请务必仔细检查您的体系结构,否则可能无法正常工作. ;)
If you're running Snow Leopard with a 64-bit CPU, then you're probably running the 64-bit version. But still be sure to double-check your architecture, otherwise it probably won't work. ;)
更多推荐
如何在雪豹上安装gem pg
发布评论