Ruby on rails 叮当声:错误:无法删除文件:安装Postgres时权限被拒绝

Ruby on rails 叮当声:错误:无法删除文件:安装Postgres时权限被拒绝,ruby-on-rails,ruby,macos,postgresql,gem,Ruby On Rails,Ruby,Macos,Postgresql,Gem,我正试图在我的机器上安装Postgres。我正在关注这个 我得到以下错误 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/Pos

我正试图在我的机器上安装Postgres。我正在关注这个

我得到以下错误

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
~:$ 

我尝试使用
sudo chmod-R 777
更改文件夹
/Applications/Postgress.app/Contents/
的权限,但没有成功。

不幸的是,这对Mac不起作用。在这里,我分享个人的经验,这是现实的,它只是工作

第一步。安装。这是“缺少的OS X软件包管理器”。如前所述,只需一个命令即可:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
它会询问您的密码一次,但是在您可以非常轻松地管理更多的软件包之后。安装自制软件后,运行
brew doctor
检查您的系统并按照说明操作。如果您有全新的Mac,它可能会要求您安装XCode和构建工具

下一个。安装PostgreSQL。

只需
brew安装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

干杯。

系统上是否安装了PostgreSQL?如果是的话,你是如何安装的?我使用了Postgres(postgresapp.com)的这个安装
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