-1

This question already has an answer here:

I am using Ubuntu 14.04 and 12.04 with the latest updates behind a proxy server at my school. I had no problem a few months ago. However, over the past two months when I try to add a repository with add-apt-repository there is no key retrieved. I can then use sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys KEY with success, but this is annoying. I have created scripts that add PPAs, install software, and more that are now failing because of this issue.

Should I be filing a bug report? If so, could someone please direct me to where to file.

Here is what my terminal output looks like when trying to add the PPA for my-weather-indicator:

$ sudo add-apt-repository ppa:atareao/atareao
 Applications from atareao
 More info: https://launchpad.net/~atareao/+archive/ubuntu/atareao
Press [ENTER] to continue or ctrl-c to cancel adding it

gpg: keyring `/tmp/tmp16ytp9px/secring.gpg' created
gpg: keyring `/tmp/tmp16ytp9px/pubring.gpg' created
gpg: requesting key 36FD5529 from hkp server keyserver.ubuntu.com
gpgkeys: key A3D8A366869FE2DC5FFD79C36A9653F936FD5529 can't be retrieved
gpg: no valid OpenPGP data found.
gpg: Total number processed: 0

$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 36FD5529
Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --homedir /tmp/tmp.fla11h2USs --no-auto-check-trustdb --trust-model always --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --keyring /etc/apt/trusted.gpg.d/steam.gpg --keyserver keyserver.ubuntu.com --recv-keys 36FD5529
gpg: requesting key 36FD5529 from hkp server keyserver.ubuntu.com
gpg: key 36FD5529: public key "Launchpad PPA for atareao" imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)

Update: I was able to get it working with the -E parameter for sudo, so the command that works is sudo -E add-apt-repository ppa:atareao/atareao. However, I don't understand why things worked without that before and now it does not. Also, this does not seem to explain why other commands with sudo work without the -E parameter. This solution comes from Ubuntu 10.10.

marked as duplicate by Eric Carvalho, muru, Charles Green, αғsнιη, Volker Siegel Nov 11 '14 at 18:12

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • That solution works, MadMike, but I don't understand why I did not need the -E a few months ago. – HarlemSquirrel Oct 30 '14 at 16:29
2

You are facing two problems:

  1. add-apt-repository is relying on the existence of the correct http_proxy and https_proxy values.

  2. sudo will not use all of the current environment values. Probably for security reasons. There are two possibilities how to overcome this:

    1. Call sudo -E add-apt-repository <additional-options>

      This will use all of the current environment.

    2. You can configure sudo to automatically copy http_proxy and https_proxy too. Do this:

      sudo visudo
      

      Add the following lines:

      Defaults env_keep +="http_proxy"
      Defaults env_keep +="https_proxy"
      

      Blantantly copied from this answer.

  • This all makes sense, but then why does sudo apt-get update work fine without any modification? – HarlemSquirrel Nov 3 '14 at 17:51
  • My guess is, that apt-get can fallback to reading /etc/apt/apt.conf or the /etc/apt/apt.conf.d/*-files and add-apt-repository doesn't. Unfortunately, this all just stuff I've looked up while wrestling with corporate proxy configurations. I don't have any first-hand "I've seen the code"-knowledge :-/ – MadMike Nov 3 '14 at 21:39
  • This makes the most sense from what I've read around the web. Thanks! – HarlemSquirrel Nov 4 '14 at 15:00

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