Friday, 27 September 2013

Unable to add ppa behind proxy

While trying to add softwares from sources other than the central debian repository, we may have to add a PPA (Personal Package Archive), so that the software(apt or aptitude) which installs other softwares fetches packages for us from the new location.

The default or normal method to add a PPA via command line is as follows:

sudo add-apt-repository ppa:something

However, if you are behind a proxy, you may not be able to add this way and when you try to do something like this:

sudo add-apt-repository ppa:gnome3-team/gnome3

you may get an error like this:

Cannot access PPA ( to get PPA information, please check your internet connection.

This may happen even if you have added your proxy using System Settings -> Network -> Network proxy or in /etc/apt/apt.conf or even in /home/$USER/.bashrc. This is because the sudo user is not aware of the proxy set in the places above. This tutorial explains how to make this work to add a PPA the terminal way.

So lets get started. Please note that all commands and text hereon are case-senstive, take care not to make any typos hereon, to avoid messing up your system):

  • Open a terminal using Ctrl + Alt + t
  • Type
    export http_proxy="http://username:password@your proxy":"port"
    export https_proxy="https://username:password@your proxy":"port"
    Remember to replace "username" by your username and "password" by your password, if applicable, "your proxy" by your proxy address like or and "port" by something like 3128.
  • Now we have two methods to export these parameter to "sudo" user:
    Method 1:
  • Type sudo visudo
  • Add Defaults env_keep="https_proxy" to the end of the file. (Note that Defaults has a capital "d")
  • Type Ctrl + x and y to save and exit.
    Method 2:
  • Whenever you use sudo command, export the environment variables of the user you are currently using. To do this, when you use sudo, use sudo -E

You are now ready to add PPA using the terminal. Please let me know, via comments, if you face any issues while doing this.
Source: The bug filed regarding this at launchpad.