user3013437
user3013437

Reputation: 93

"bundle install" error: cannot open .git/FETCH_HEAD: Permission denied

I recently changed my ubuntu to Linux mint so i need to re-install my gems but it gives me this error....

Steps i have done


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'

Upvotes: 7

Views: 8195

Answers (4)

Shiva
Shiva

Reputation: 12592

In my case I am using rbenv and faced the same issue while bundle install.

Reason

while cloning the rbenv from its repo I unknowigly used sudo like

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

This makes sudo the owner of the directory and other users have no permission to access the repo.

Solution

Don't know if it is the best way to solve this issue; sorry

I changed the permission of the directory ~/.rbenv

sudo chmod 777 ~/.rbenv/**

Upvotes: 0

jonnysamps
jonnysamps

Reputation: 1086

If you are using rvm, From the command line run:

~> rvm fix-permissions

This solved that kind of error for me.

Upvotes: 15

boulder_ruby
boulder_ruby

Reputation: 39763

bundle exec bundle install

worked for me. I made the mistake of installing ruby when I was logged in as root so I have to do this now until I fix the problem.

Upvotes: 1

Andrew
Andrew

Reputation: 580

I experienced the same issue when upgrading bundler ... it turns out the cache directory in the bundle system install location was causing the issue .. purging this completely fixed the problem - this was on OSX, not using RVM, but the standard OSX ruby on 10.10.3

Upvotes: 0

Related Questions