捆绑安装不起作用 - Git权限被拒绝

时间:2016-08-28 12:57:03

标签: ruby-on-rails ruby git

我尝试使用终端命令'Rails S'在本地服务器上运行我的Ruby on Rails应用程序但是我被要求将所有宝石捆绑到这台笔记本电脑上 - Osx

这是终端输出:

Johns-MacBook-Pro-2:spu-test JohnSmith$ rails s
Could not find coffee-rails-4.0.1 in any of the sources
Run `bundle install` to install missing gems.
Johns-MacBook-Pro-2:spu-test JohnSmith$ bundle install
Fetching gem metadata from https://rubygems.org/
Fetching version metadata from https://rubygems.org/
Fetching dependency metadata from https://rubygems.org/
error: cannot open .git/FETCH_HEAD: Permission denied

Retrying git fetch --force --quiet --tags "/Users/JohnSmith/.bundle/cache/git/active_admin-d67faab65e9b74efbc8efb4a777a851e9f78b2ca" due to error (2/4): Bundler::Source::Git::GitCommandError Git error: command `git fetch --force --quiet --tags "/Users/JohnSmith/.bundle/cache/git/active_admin-d67faab65e9b74efbc8efb4a777a851e9f78b2ca"` in directory /Library/Ruby/Gems/2.0.0/bundler/gems/active_admin-3d7605f82706 has failed.
If this error persists you could try removing the cache directory '/Users/JohnSmith/.bundle/cache/git/active_admin-d67faab65e9b74efbc8efb4a777a851e9f78b2ca'
error: cannot open .git/FETCH_HEAD: Permission denied

Retrying git fetch --force --quiet --tags "/Users/JohnSmith/.bundle/cache/git/active_admin-d67faab65e9b74efbc8efb4a777a851e9f78b2ca" due to error (3/4): Bundler::Source::Git::GitCommandError Git error: command `git fetch --force --quiet --tags "/Users/JohnSmith/.bundle/cache/git/active_admin-d67faab65e9b74efbc8efb4a777a851e9f78b2ca"` in directory /Library/Ruby/Gems/2.0.0/bundler/gems/active_admin-3d7605f82706 has failed.
If this error persists you could try removing the cache directory '/Users/JohnSmith/.bundle/cache/git/active_admin-d67faab65e9b74efbc8efb4a777a851e9f78b2ca'
error: cannot open .git/FETCH_HEAD: Permission denied

Retrying git fetch --force --quiet --tags "/Users/JohnSmith/.bundle/cache/git/active_admin-d67faab65e9b74efbc8efb4a777a851e9f78b2ca" due to error (4/4): Bundler::Source::Git::GitCommandError Git error: command `git fetch --force --quiet --tags "/Users/JohnSmith/.bundle/cache/git/active_admin-d67faab65e9b74efbc8efb4a777a851e9f78b2ca"` in directory /Library/Ruby/Gems/2.0.0/bundler/gems/active_admin-3d7605f82706 has failed.
If this error persists you could try removing the cache directory '/Users/JohnSmith/.bundle/cache/git/active_admin-d67faab65e9b74efbc8efb4a777a851e9f78b2ca'
error: cannot open .git/FETCH_HEAD: Permission denied

Git error: command `git fetch --force --quiet --tags
"/Users/JohnSmith/.bundle/cache/git/active_admin-d67faab65e9b74efbc8efb4a777a851e9f78b2ca"`
in directory /Library/Ruby/Gems/2.0.0/bundler/gems/active_admin-3d7605f82706 has
failed.
If this error persists you could try removing the cache directory
'/Users/JohnSmith/.bundle/cache/git/active_admin-d67faab65e9b74efbc8efb4a777a851e9f78b2ca'
Johns-MacBook-Pro-2:spu-test JohnSmith$

删除缓存目录后使用sudo bundle install的错误:

Johns-MacBook-Pro-2:spu-test JohnSmith$ sudo bundle install
Password:
Don't run Bundler as root. Bundler can ask for sudo if it is needed, and
installing your bundle as root will break this application for all non-root
users on this machine.
Fetching gem metadata from https://rubygems.org/
Fetching version metadata from https://rubygems.org/
Fetching dependency metadata from https://rubygems.org/
Rubygems 2.0.14.1 is not threadsafe, so your gems will be installed one at a time. Upgrade to Rubygems 2.1.0 or higher to enable parallel gem installation.
Using rake 10.3.2
Using Ascii85 1.0.2
Using i18n 0.6.9
Using minitest 4.7.5
Using multi_json 1.10.1
Using thread_safe 0.3.4
Using tzinfo 0.3.39
Using builder 3.1.4
Using erubis 2.7.0
Using rack 1.5.2
Using mime-types 1.25.1
Using polyglot 0.3.5
Using sass 3.2.19
Using thor 0.19.1
Using coffee-script-source 1.7.0
Using execjs 2.1.0
Using activerecord-deprecated_finders 1.0.3
Using arel 4.0.2
Using bundler 1.12.5
Using hike 1.2.3
Using tilt 1.4.1
Using addressable 2.3.6
Using afm 0.2.1
Using aws_cf_signer 0.1.3
Using bcrypt 3.1.7
Using cancan 2.0.0.alpha from git://github.com/ryanb/cancan.git (at 2.0@e6bf4c8)
Using json 1.8.1
Using orm_adapter 0.5.0
Using excon 0.42.0
Using geocoder 1.2.4
Using gmaps4rails 2.1.2
Using hashery 2.1.1
Using pdf-core 0.1.6
Using ruby-rc4 0.1.5
Using ttfunk 1.1.1
Installing pg 0.17.1 with native extensions

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
checking for pg_config... yes
Using config values from /usr/local/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... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
    --with-pg
    --without-pg
    --with-pg-config
    --without-pg-config
    --with-pg_config
    --without-pg_config
    --with-pg-dir
    --without-pg-dir
    --with-pg-include
    --without-pg-include=${pg-dir}/include
    --with-pg-lib
    --without-pg-lib=${pg-dir}/
    --with-pqlib
    --without-pqlib
    --with-libpqlib
    --without-libpqlib
    --with-ms/libpqlib
    --without-ms/libpqlib


Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/pg-0.17.1 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/gems/pg-0.17.1/ext/gem_make.out
Using rails3_serve_static_assets 0.0.1 from git://github.com/heroku/rails3_serve_static_assets.git (at master@84910ce)
Using rails_log_stdout 0.0.1 from git://github.com/heroku/rails_log_stdout.git (at master@f9a9275)
Using underscore-rails 1.6.0
Using will_paginate 3.0.5
Using activesupport 4.0.5
Using rack-test 0.6.2
Using warden 1.2.3
Using rest-client 1.6.7
Using treetop 1.4.15
Using bourbon 3.2.3
Using coffee-script 2.2.0
Using sprockets 2.11.0
Using rdoc 4.1.1
Using uglifier 2.5.0
Using mandrill-api 1.0.53
Using pdf-reader 1.3.3
Using prawn 0.15.0
An error occurred while installing pg (0.17.1), and Bundler cannot continue.
Make sure that `gem install pg -v '0.17.1'` succeeds before bundling.

1 个答案:

答案 0 :(得分:1)

我遇到了同样的问题,我就这样解决了。

  1. 备份您当前的.bundle和供应商目录
  2. 然后删除两个目录
  3. 运行bundle clean --force
  4. 最后,运行bundle install --path vendor/cache
  5. bundle install --path vendor/cache

    您的问题将得到解决。 :)