"bundle install"错误:无法打开.git / FETCH_HEAD:权限被拒绝。

7

我最近将我的ubuntu更换为Linux mint,所以我需要重新安装我的gems,但是它给了我这个错误...

我已经完成的步骤

  • 生成了公钥/私钥并添加到github中。
  • 重新运行命令“bundle install”,但它没有起作用。

Fetching git://github.com/seuros/capistrano-puma.git
error: cannot open .git/FETCH_HEAD: Permission denied

Retrying git fetch --force --quiet --tags 


"/home/asad/.bundler/cache/git/capistrano-puma-e90ae8bdcca081264c0ff67caa1d11e89f7a01e0" due to error (2/3): Bundler::Source::Git::GitCommandError Git error: command `git fetch --force --quiet --tags "/home/asad/.bundler/cache/git/capistrano-puma-e90ae8bdcca081264c0ff67caa1d11e89f7a01e0"` in directory /usr/local/rvm/gems/ruby-2.0.0-p598/bundler/gems/capistrano-puma-7748efb9a53d has failed.
        If this error persists you could try removing the cache directory '/home/asad/.bundler/cache/git/capistrano-puma-e90ae8bdcca081264c0ff67caa1d11e89f7a01e0'
        error: cannot open .git/FETCH_HEAD: Permission denied

        Retrying git fetch --force --quiet --tags "/home/asad/.bundler/cache/git/capistrano-puma-e90ae8bdcca081264c0ff67caa1d11e89f7a01e0" due to error (3/3): Bundler::Source::Git::GitCommandError Git error: command `git fetch --force --quiet --tags "/home/asad/.bundler/cache/git/capistrano-puma-e90ae8bdcca081264c0ff67caa1d11e89f7a01e0"` in directory /usr/local/rvm/gems/ruby-2.0.0-p598/bundler/gems/capistrano-puma-7748efb9a53d has failed.
        If this error persists you could try removing the cache directory '/home/asad/.bundler/cache/git/capistrano-puma-e90ae8bdcca081264c0ff67caa1d11e89f7a01e0'
        error: cannot open .git/FETCH_HEAD: Permission denied

        Git error: command `git fetch --force --quiet --tags "/home/asad/.bundler/cache/git/capistrano-puma-e90ae8bdcca081264c0ff67caa1d11e89f7a01e0"` in directory
        /usr/local/rvm/gems/ruby-2.0.0-p598/bundler/gems/capistrano-puma-7748efb9a53d has failed.
        If this error persists you could try removing the cache directory '/home/asad/.bundler/cache/git/capistrano-puma-e90ae8bdcca081264c0ff67caa1d11e89f7a01e0'

尝试将 gem 'capistrano3-puma', github: "seuros/capistrano-puma" 更改为 gem 'capistrano3-puma', group: :development。这样应该可以正常工作。 - usmanali
4个回答

16

如果您正在使用 rvm,请从命令行运行:

~> rvm fix-permissions

这个方法解决了我遇到的那种错误。


1
bundle exec bundle install

对我有帮助。我犯了一个错误,以root用户身份安装了ruby,所以现在必须这样做,直到我解决问题为止。


0
在我的情况下,我正在使用 rbenv 并在运行 bundle install 时遇到了相同的问题。

原因

在克隆来自其 repo 的rbenv时,我不知情地使用了sudo 命令。

sudo git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build

这将会使sudo成为目录的所有者,其他用户将无权访问仓库。

解决方案

不知道这是否是解决此问题的最佳方法;抱歉

我改变了目录~/.rbenv的权限

sudo chmod 777 ~/.rbenv/**

0

当我升级bundler时,我遇到了同样的问题...事实证明,捆绑系统安装位置中的缓存目录导致了这个问题...完全清除它可以完全解决这个问题-这是在OSX上,没有使用RVM,而是标准的OSX ruby on 10.10.3。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接