Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

E: Unable to locate package git - Ubuntu on EC2

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.

like image 241
gabrtv Avatar asked Sep 15 '12 16:09

gabrtv


People also ask

How do I connect to AWS EC2 instance Ubuntu?

Open the Amazon EC2 console. In the left navigation pane, choose Instances and select the instance to which to connect. Choose Connect. On the Connect To Your Instance page, choose EC2 Instance Connect (browser-based SSH connection), Connect.


2 Answers

Update apt-get packages, run the following command:

$ apt-get update 
like image 121
Nasser Al-Wohaibi Avatar answered Oct 18 '22 23:10

Nasser Al-Wohaibi


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.

like image 28
gabrtv Avatar answered Oct 18 '22 22:10

gabrtv