[英]Cannot install PG gem on Mac OSX
I created a new rails app: rails new -d postgresql我创建了一个新的 rails 应用程序: rails new -d postgresql
However, I cannot get the pg gem to install.但是,我无法安装 pg gem。 I had previously installed postgres using brew and it starts up automatically with my Mac.
我之前使用 brew 安装了 postgres,它会在我的 Mac 上自动启动。
I have tried several things posted here on SO.我已经尝试了在 SO 上发布的几件事。 I am using ruby 2.0.
我正在使用红宝石 2.0。 When running bundle install, I get the error:
运行 bundle install 时,出现错误:
Errno::EACCES: Permission denied - /Library/Ruby/Gems/2.0.0/gems/pg-0.17.1/.gemtest
Errno::EACCES:权限被拒绝 - /Library/Ruby/Gems/2.0.0/gems/pg-0.17.1/.gemtest
An error occurred while installing pg (0.17.1), and Bundler cannot continue.
安装 pg (0.17.1) 时出错,Bundler 无法继续。
Make sure that
gem install pg -v '0.17.1'
succeeds before bundling.在捆绑之前确保
gem install pg -v '0.17.1'
成功。
I tried downloading the postgresapp, but when I try to start it, there is an obvious conflict b/c it says: could not start on Port 5432. Not sure if this is causing an issue or not.我尝试下载 postgresapp,但是当我尝试启动它时,有一个明显的 b/c 冲突,它说:无法在端口 5432 上启动。不确定这是否导致问题。
I also tried this:我也试过这个:
sudo env ARCHFLAGS="-arch x86_64" gem install pg -- --with-pg-
config=/Users/david/Library/Application Support/Postgres/var-9.3/postgresql.conf
And got the error: Failed to build gem native extension.并得到错误:无法构建 gem 本机扩展。
I am a fairly new programmer, so please be as detailed as possible in your response.我是一个相当新的程序员,所以请在你的回复中尽可能详细。 Thanks!
谢谢!
FIXED : I followed Justin's advice below and then did a restart.修正:我遵循了下面贾斯汀的建议,然后重新启动。 After that, I reran 'bundle install' and the pg gem finally installed!
之后,我重新运行“捆绑安装”,最终安装了 pg gem!
First, you should update your Xcode Tools since you are on MacOS.首先,您应该更新您的 Xcode 工具,因为您使用的是 MacOS。 Here is a good post on that: Installing PG gem on OS X - failure to build native extension
这是一篇很好的文章: 在 OS X 上安装 PG gem - 无法构建本机扩展
Then, I would go ahead and get a fresh instance of Postgres installed via Homebrew
.然后,我会继续通过
Homebrew
安装一个新的 Postgres 实例。 First, uninstall it首先,卸载它
brew uninstall postgresql
I would say run brew update
, but the link I mentioned has you updating Homebrew.我会说运行
brew update
,但我提到的链接让你更新 Homebrew。 Now reinstall postgres with现在重新安装 postgres
brew install postgresql
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.