Looks to me like there may be a problem with the Ubuntu EC2 mirrors. After a fresh apt-get update, I'm seeting this:

$ apt-get install -yq git
E: Unable to locate package git

After a few more apt-get's, it will often succeed.

share|improve this question

Update apt-get packages, run the following command:

$ apt-get update 
share|improve this answer
    
Not sure you understood the question. The issue is that apt-get update returns different results due to upstream mirrors being broken. – gabrtv Feb 20 '13 at 21:57
1  
My bad then, it is just that I have faced the same issue which got resolved by only a simple $ apt-get update – Nasser Al-Wohaibi Feb 24 '13 at 8:42
2  
+1 This actually worked for me. – Ataraxia Apr 18 '13 at 21:42
up vote 10 down vote accepted

The mirrors still seem to be broken, but I was able to work around the issue with a dumb loop:

# stupid loop to get around ubuntu package mirror problems
for attempt in 1 2 3; do
  if [ ! -z "`which git`" ]; then
    break
  fi
  echo "Trying to install git, attempt $attempt"
  sudo apt-get update -yq --fix-missing
  sudo apt-get install -yq git
done

3 attempts is usually enough to find a working mirror.

share|improve this answer
1  
You sir, are fantastic! – mattdlockyer Apr 22 '13 at 14:17
    
You made my day! Thanks! – Marian Nov 8 '13 at 7:57
    
I would've expected the mirrors to be fixed by now. Glad this still helps though! – gabrtv Nov 8 '13 at 15:48
    
You made my day also :) Thank you – Ahmed Abobakr Dec 26 '13 at 21:22
    
Didn't work for me. I have set 5 atempts and each time I get : Reading package lists... Reading package lists... Building dependency tree... Reading state information... E: Unable to locate package git... Please help me ! – Cherif Mar 6 '14 at 10:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.