ruby-on-rails - clang : error: unable to remove file: Permission denied when installing Postgres

标签 ruby-on-rails ruby macos postgresql rubygems

我正在尝试在我的机器上安装 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
~:$ 

我尝试使用 sudo chmod -R 777 更改文件夹 /Applications/Postgress.app/Contents/ 的权限,但无济于事。

最佳答案

不幸的是,这不适用于 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

干杯。

关于ruby-on-rails - clang : error: unable to remove file: Permission denied when installing Postgres,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33316360/

相关文章:

mysql - 无法使用 ActiveRecord 从 Rake 任务执行 MySQL sql "source"命令

ruby-on-rails - "resources :post, except: :new"使 Rails 认为路线/帖子/新将指向帖子 ID "new"

ruby-on-rails - Ruby/Rails 应用程序测试 - 模拟 Http 服务/响应

ruby-on-rails - Ruby On Rails libyaml

python - 无法在 Maverick 上安装 psycopg2

macos - OSX 中 gcc 使用什么文件格式?

ruby-on-rails - 与 SQLite 和 PostgreSQL 兼容的 LIKE 查询

ruby-on-rails - 如何在 Devise 中注册后禁用自动登录

ruby-on-rails - Rails 5 ActiveRecord 查询 - 可以加入 3 个表吗?

python - Django with mysql安装模块macos