我试图在我的机器上安装Postgres。我跟着这个answer。
gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config
我收到以下错误
Last login: Sat Oct 24 19:55:19 on ttys004
~:$ gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config
Building native extensions with: '--with-pg-config=/Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config'
This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/usr/local/opt/ruby/bin/ruby -r ./siteconf20151024-73485-3y70nd.rb extconf.rb --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config
Using config values from /Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... yes
checking for PQconnectionUsedPassword()... yes
checking for PQisthreadsafe()... yes
checking for PQprepare()... yes
checking for PQexecParams()... yes
checking for PQescapeString()... yes
checking for PQescapeStringConn()... yes
checking for PQescapeLiteral()... yes
checking for PQescapeIdentifier()... yes
checking for PQgetCancel()... yes
checking for lo_create()... yes
checking for pg_encoding_to_char()... yes
checking for pg_char_to_encoding()... yes
checking for PQsetClientEncoding()... yes
checking for PQlibVersion()... yes
checking for PQping()... yes
checking for PQsetSingleRowMode()... yes
checking for PQconninfo()... yes
checking for rb_encdb_alias()... yes
checking for rb_enc_alias()... no
checking for rb_thread_call_without_gvl()... yes
checking for rb_thread_call_with_gvl()... yes
checking for rb_thread_fd_select()... yes
checking for rb_w32_wrap_io_handle()... no
checking for rb_str_modify_expand()... yes
checking for rb_hash_dup()... yes
checking for PGRES_COPY_BOTH in libpq-fe.h... yes
checking for PGRES_SINGLE_TUPLE in libpq-fe.h... yes
checking for PG_DIAG_TABLE_NAME in libpq-fe.h... yes
checking for struct pgNotify.extra in libpq-fe.h... yes
checking for unistd.h... yes
checking for ruby/st.h... yes
checking for C99 variable length arrays... yes
creating extconf.h
creating Makefile
make "DESTDIR=" clean
rm: pg_ext.bundle: Permission denied
rm: gvl_wrappers.o: Permission denied
rm: pg.o: Permission denied
rm: pg_binary_decoder.o: Permission denied
rm: pg_binary_encoder.o: Permission denied
rm: pg_coder.o: Permission denied
rm: pg_connection.o: Permission denied
rm: pg_copy_coder.o: Permission denied
rm: pg_errors.o: Permission denied
rm: pg_result.o: Permission denied
rm: pg_text_decoder.o: Permission denied
rm: pg_text_encoder.o: Permission denied
rm: pg_type_map.o: Permission denied
rm: pg_type_map_all_strings.o: Permission denied
rm: pg_type_map_by_class.o: Permission denied
rm: pg_type_map_by_column.o: Permission denied
rm: pg_type_map_by_mri_type.o: Permission denied
rm: pg_type_map_by_oid.o: Permission denied
rm: pg_type_map_in_ruby.o: Permission denied
rm: util.o: Permission denied
rm: .RUBYARCHDIR.time: Permission denied
make: [clean] Error 1 (ignored)
make "DESTDIR="
compiling gvl_wrappers.c
error: unable to rename temporary 'gvl_wrappers.o-4970f416' to output file 'gvl_wrappers.o': 'Permission denied'
1 error generated.
clang: error: unable to remove file: Permission denied
make: *** [gvl_wrappers.o] Error 1
make failed, exit code 2
Gem files will remain installed in /usr/local/lib/ruby/gems/2.2.0/gems/pg-0.18.3 for inspection.
Results logged to /usr/local/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-14/2.2.0/pg-0.18.3/gem_make.out
~:$
我尝试使用/Applications/Postgress.app/Contents/
更改文件夹sudo chmod -R 777
的权限无效。
答案 0 :(得分:1)
不幸的是,这对Mac无效。在这里,我分享了现在实际的个人经历,它只是有效。
第一步。安装Homebrew。这是“OS X缺少的软件包管理器”。如所声称的那样,您只能使用一个命令来执行此操作:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
它会询问您的密码一次,但是您可以非常轻松地管理更多的软件包。安装Homebrew后,运行brew doctor
以检查系统并按照说明操作。如果你有全新的Mac,它可能会要求你安装XCode和构建工具。
下一步。安装PostgreSQL。
就像brew install postgres
一样简单。这需要一段时间来下载PostgreSQL及其依赖项。如果您需要比最新版本更早的确切版本,请使用brew search postgres
找到您需要的版本。
最后。安装pq
gem。
这里没有诀窍:
gem install pg
Fetching: pg-0.18.3.gem (100%)
Building native extensions. This could take a while...
Successfully installed pg-0.18.3
1 gem installed
干杯。